ci(release): add step to install CLI dependencies in release workflow #78
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*'] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| version: | |
| name: Determine Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| is_preview: ${{ steps.version.outputs.is_preview }} | |
| steps: | |
| - name: Set version | |
| id: version | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| if [[ "$TAG" == *-preview-* ]]; then | |
| echo "version=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "is_preview=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "version=${TAG}+${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" | |
| echo "is_preview=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| docker: | |
| name: Build & Push Docker Image | |
| needs: version | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/metadata-action@v5 | |
| id: meta | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=${{ needs.version.outputs.is_preview == 'true' && 'preview' || 'latest' }} | |
| type=raw,value=${{ github.ref_name }} | |
| type=sha,prefix= | |
| - uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| VERSION=${{ needs.version.outputs.version }} | |
| cli: | |
| name: Build CLI Binary | |
| needs: version | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: zero-linux | |
| - os: macos-latest | |
| target: zero-macos | |
| - os: windows-latest | |
| target: zero-windows.exe | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: Install CLI dependencies | |
| working-directory: cli | |
| run: bun install --frozen-lockfile | |
| - name: Inject version | |
| shell: bash | |
| run: sed -i.bak "s/__VERSION__/${{ needs.version.outputs.version }}/g" cli/src/version.ts | |
| - name: Build CLI | |
| run: bun build cli/src/main.ts --compile --outfile ${{ matrix.target }} | |
| - uses: actions/upload-artifact@v5 | |
| with: | |
| name: ${{ matrix.target }} | |
| path: ${{ matrix.target }} | |
| retention-days: 1 | |
| release: | |
| name: Create GitHub Release | |
| needs: [version, cli] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: zero-linux | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: zero-macos | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: zero-windows.exe | |
| path: artifacts/ | |
| - name: Make binaries executable | |
| run: chmod +x artifacts/zero-* | |
| - uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| draft: true | |
| prerelease: ${{ needs.version.outputs.is_preview == 'true' }} | |
| files: artifacts/zero-* | |
| - name: Publish release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh release edit "${{ github.ref_name }}" --draft=false --repo "${{ github.repository }}" |