fix(ci): 馃敡 Correct workflow trigger and upgrade actions #5
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[0-9]+.[0-9]+.[0-9]+' | |
| pull_request: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| dev: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.23' | |
| - name: Set build environment variables | |
| run: | | |
| echo "BUILD_DATE=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV | |
| echo "GO_VERSION=$(go version)" >> $GITHUB_ENV | |
| - name: Get latest tag and set GORELEASER_CURRENT_TAG | |
| run: | | |
| TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| echo "GORELEASER_CURRENT_TAG=${TAG}-dev" >> $GITHUB_ENV | |
| - name: Debug GoReleaser Environment Variables | |
| run: | | |
| echo "BRANCH_NAME: ${{ github.ref_name }}" | |
| echo "BUILD_DATE: ${{ env.BUILD_DATE }}" | |
| echo "GO_VERSION: ${{ env.GO_VERSION }}" | |
| echo "GORELEASER_CURRENT_TAG: ${{ env.GORELEASER_CURRENT_TAG }}" | |
| echo "PATH: $PATH" | |
| echo "Current directory: $(pwd)" | |
| ls -l .goreleaser.dev.yaml | |
| - name: Run linter | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: v2.3.1 | |
| args: --verbose | |
| - name: Run GoReleaser Dev | |
| uses: goreleaser/goreleaser-action@v7 | |
| with: | |
| distribution: goreleaser | |
| version: '~> v2' | |
| args: --snapshot --clean --skip=sign --config .goreleaser.dev.yaml | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GORELEASER_CURRENT_TAG: ${{ env.GORELEASER_CURRENT_TAG }} | |
| BUILD_USER: "${{ github.actor }}" | |
| BUILD_DATE: ${{ env.BUILD_DATE }} | |
| GO_VERSION: ${{ env.GO_VERSION }} | |
| BRANCH_NAME: ${{ github.ref_name }} | |
| REVISION: ${{ github.sha }} | |
| - name: Rename Dev Archive | |
| run: | | |
| mv dist/prometheus-cli.dev.tar.gz dist/prometheus-cli.${{ env.GORELEASER_CURRENT_TAG }}.branch-${{ github.ref_name }}.${{ env.BUILD_DATE }}.tar.gz | |
| - name: Upload Dev Archive (Linux AMD64) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prometheus-cli.${{ env.GORELEASER_CURRENT_TAG }}.branch-${{ github.ref_name }}.${{ env.BUILD_DATE }}.tar.gz | |
| path: dist/prometheus-cli.${{ env.GORELEASER_CURRENT_TAG }}.branch-${{ github.ref_name }}.${{ env.BUILD_DATE }}.tar.gz | |
| - name: Upload Checksums | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: prometheus-cli_checksums.txt | |
| path: dist/prometheus-cli_checksums.txt | |
| release: | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.23' | |
| - name: Set build environment variables | |
| run: | | |
| echo "BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV | |
| echo "GO_VERSION=$(go version)" >> $GITHUB_ENV | |
| - name: Run linter | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: v2.3.1 | |
| args: --verbose | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v7 | |
| with: | |
| distribution: goreleaser | |
| version: '~> v2' | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} | |
| BUILD_USER: "${{ github.actor }}" | |
| BUILD_DATE: ${{ env.BUILD_DATE }} | |
| GO_VERSION: ${{ env.GO_VERSION }} | |
| BRANCH_NAME: ${{ github.ref_name }} | |
| REVISION: ${{ github.sha }} |