Repository navigation
chore: simplify build and release workflows #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,6 @@ | ||
| <!-- Title: type(scope): summary, for example "feat(backend): accept resource labels". See CONTRIBUTING.md. --> | ||
|
|
||
| ## What and why | ||
|
|
||
| ## How it was tested | ||
|
|
||
| - [ ] `npm test` passes in the root and in `backend/` | ||
| - [ ] The README is updated if behavior or the API changed | ||
| - [ ] A breaking change is marked with `!` in the title and described above |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
|
|
||
| name: Build and test | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| verify: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| dir: [., backend] | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ matrix.dir }} | ||
| steps: | ||
| - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
|
|
||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| cache-dependency-path: ${{ matrix.dir }}/package-lock.json | ||
|
|
||
| - run: npm ci | ||
| - run: npm test | ||
| - run: npm run build |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,73 +1,78 @@ | ||
| name: Build and release | ||
| name: Release | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| verify: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| dir: [., backend] | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ matrix.dir }} | ||
| steps: | ||
| - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| cache-dependency-path: ${{ matrix.dir }}/package-lock.json | ||
| - run: npm ci | ||
| - run: npm test | ||
| - run: npm run build | ||
|
|
||
| release: | ||
| if: github.event_name == 'push' | ||
| needs: verify | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
| concurrency: | ||
| group: release | ||
| group: release-${{ github.ref }} | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| steps: | ||
| - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | ||
| with: | ||
| node-version: 24 | ||
| registry-url: https://registry.npmjs.org | ||
| - name: Publish both packages and tag the release | ||
|
|
||
| - name: Get release version from tag | ||
| id: version | ||
| run: | | ||
| version=$(scripts/next-version.sh) | ||
| if [ -z "$version" ]; then | ||
| echo "Nothing to release since the last tag" | ||
| exit 0 | ||
| tag="${GITHUB_REF_NAME}" | ||
| version="${tag#v}" | ||
|
|
||
| if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "::error::Invalid release tag: $tag. Expected vX.Y.Z." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "version=$version" >> "$GITHUB_OUTPUT" | ||
| echo "Releasing version $version" | ||
|
|
||
| - name: Publish both packages | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| run: | | ||
| for dir in . backend; do | ||
| name=$(npm pkg get name --prefix "$dir" | tr -d '"') | ||
| if npm view "$name@$version" version >/dev/null 2>&1; then | ||
| continue | ||
| fi | ||
| ( | ||
| cd "$dir" | ||
|
|
||
| name=$(npm pkg get name | tr -d '"') | ||
|
|
||
| if npm view "$name@$VERSION" version >/dev/null 2>&1; then | ||
| echo "$name@$VERSION already published, skipping" | ||
| exit 0 | ||
| fi | ||
|
|
||
| npm ci | ||
| npm version "$VERSION" --no-git-tag-version | ||
| npm pkg set main=dist/index.js types=dist/index.d.ts | ||
| npm run build | ||
| npm pkg set version="$version" main=dist/index.js types=dist/index.d.ts | ||
| npm publish | ||
| ) | ||
| done | ||
| git tag "v$version" | ||
| git push origin "v$version" | ||
| (cd backend && npm ci && npm run openapi:generate -- "$version") | ||
| gh release create "v$version" backend/dist/openapi.yaml --generate-notes --verify-tag | ||
|
|
||
| - name: Generate OpenAPI specification | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| cd backend | ||
| npm ci | ||
| npm run openapi:generate -- "$VERSION" | ||
|
|
||
| - name: Create GitHub release | ||
| run: | | ||
| gh release create "$GITHUB_REF_NAME" backend/dist/openapi.yaml \ | ||
| --generate-notes \ | ||
| --verify-tag | ||
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.