feat(cli): project build-logs from Firebase via control plane (#82) #171
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: | |
| branches: [main] | |
| tags: ['v*'] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., v1.0.0)' | |
| required: false | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| pull-requests: read | |
| issues: read | |
| actions: write | |
| jobs: | |
| # Test before release | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Run tests | |
| run: | | |
| go test -v ./... | |
| go vet ./... | |
| - name: Check build | |
| run: | | |
| go build -v . | |
| # Create release | |
| release: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Go | |
| uses: actions/setup-go@7b8cf10d4e4a01d4992d18a89f4d7dc5a3e6d6f4 # v4 | |
| with: | |
| go-version: '1.25' | |
| cache: true | |
| - name: Configure Git | |
| run: | | |
| git config user.name "pipeops-bot" | |
| git config user.email "bot@pipeops.io" | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| elif [[ $GITHUB_REF == refs/tags/* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| else | |
| # Auto-increment version | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| echo "Latest tag: $LATEST_TAG" | |
| # Extract version numbers | |
| MAJOR=$(echo $LATEST_TAG | sed 's/v//' | cut -d. -f1) | |
| MINOR=$(echo $LATEST_TAG | sed 's/v//' | cut -d. -f2) | |
| PATCH=$(echo $LATEST_TAG | sed 's/v//' | cut -d. -f3) | |
| # Increment patch version | |
| PATCH=$((PATCH + 1)) | |
| VERSION="v${MAJOR}.${MINOR}.${PATCH}" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version to release: $VERSION" | |
| - name: Create and push tag | |
| if: github.event_name != 'workflow_dispatch' || github.event.inputs.version == '' | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| git tag -a $VERSION -m "Release $VERSION" | |
| git push origin $VERSION | |
| - name: Install GoReleaser | |
| uses: goreleaser/goreleaser-action@5fdedb94abba051217030cc86d4523cf3f02243d # v4 | |
| with: | |
| install-only: true | |
| version: latest | |
| - name: Run GoReleaser | |
| run: | | |
| goreleaser release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} | |
| # AUR_KEY: ${{ secrets.AUR_KEY }} | |
| # Publish Docker images | |
| docker: | |
| needs: [test, release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker images | |
| uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ghcr.io/pipeopshq/pipeops-cli:latest | |
| ghcr.io/pipeopshq/pipeops-cli:${{ needs.release.outputs.version }} | |
| labels: | | |
| org.opencontainers.image.title=PipeOps CLI | |
| org.opencontainers.image.description=Official command line tool for PipeOps | |
| org.opencontainers.image.url=https://github.com/PipeOpsHQ/pipeops-cli | |
| org.opencontainers.image.source=https://github.com/PipeOpsHQ/pipeops-cli | |
| org.opencontainers.image.version=${{ needs.release.outputs.version }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.licenses=MIT | |
| # Update installation instructions | |
| update-docs: | |
| needs: [release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update README with latest version | |
| run: | | |
| VERSION=${{ needs.release.outputs.version }} | |
| # Update installation URLs in README | |
| sed -i "s|releases/download/v[0-9]*\.[0-9]*\.[0-9]*|releases/download/$VERSION|g" Readme.md | |
| # Update version references | |
| sed -i "s|pipeops-cli@v[0-9]*\.[0-9]*\.[0-9]*|pipeops-cli@$VERSION|g" Readme.md | |
| - name: Commit documentation updates | |
| run: | | |
| git config user.name "pipeops-bot" | |
| git config user.email "bot@pipeops.io" | |
| if git diff --quiet; then | |
| echo "No documentation changes to commit" | |
| else | |
| git add Readme.md | |
| git commit -m "docs: update installation links for ${{ needs.release.outputs.version }}" | |
| git push | |
| fi | |
| # Notify on completion | |
| notify: | |
| needs: [release, docker, update-docs] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Notify success | |
| if: needs.release.result == 'success' && needs.docker.result == 'success' | |
| run: | | |
| echo "🎉 Successfully released PipeOps CLI ${{ needs.release.outputs.version }}" | |
| echo "📦 Binaries: https://github.com/PipeOpsHQ/pipeops-cli/releases/tag/${{ needs.release.outputs.version }}" | |
| echo "🐳 Docker: ghcr.io/pipeopshq/pipeops-cli:${{ needs.release.outputs.version }}" | |
| - name: Notify failure | |
| if: failure() | |
| run: | | |
| echo "❌ Release failed for version ${{ needs.release.outputs.version }}" | |
| echo "Check the workflow logs for details." |