Release #35
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| env: | |
| GHCR_IMAGE: ghcr.io/vanszs/vansrouter | |
| jobs: | |
| check-branch: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is-main: ${{ steps.check.outputs.is-main }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify tag/commit is on main | |
| id: check | |
| run: | | |
| git fetch origin main | |
| if git merge-base --is-ancestor HEAD origin/main; then | |
| echo "is-main=true" >> "$GITHUB_OUTPUT" | |
| echo "✅ Release target is on main" | |
| else | |
| echo "is-main=false" >> "$GITHUB_OUTPUT" | |
| echo "⛔ Release skipped: tag is not on main" | |
| fi | |
| build-and-push-ghcr: | |
| needs: check-branch | |
| if: needs.check-branch.outputs.is-main == 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.GHCR_IMAGE }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=${{ env.GHCR_IMAGE }}:buildcache | |
| cache-to: type=registry,ref=${{ env.GHCR_IMAGE }}:buildcache,mode=max | |
| platforms: linux/amd64,linux/arm64 | |
| provenance: false | |
| sbom: false | |
| publish-npm: | |
| needs: check-branch | |
| if: needs.check-branch.outputs.is-main == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org/ | |
| - name: Configure pnpm hoisting config | |
| shell: bash | |
| run: | | |
| echo "public-hoist-pattern=*" >> .npmrc | |
| echo "shamefully-hoist=true" >> .npmrc | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Install CLI package devDependencies | |
| # cli/ is not in pnpm-workspace.yaml, so its devDependencies (esbuild) | |
| # are not installed by `pnpm install`. Install them here so the CLI | |
| # build script (which requires esbuild) can run. | |
| run: npm install --prefix cli --no-audit --no-fund | |
| - name: Configure npm authentication | |
| run: | | |
| echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Build and publish CLI package | |
| run: npm publish ./cli | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |