Publish #14
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: Publish | |
| permissions: | |
| checks: write | |
| contents: write | |
| pull-requests: write | |
| statuses: write | |
| id-token: write | |
| "on": | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - .speakeasy/gen.lock | |
| workflow_dispatch: {} | |
| jobs: | |
| release: | |
| name: Create Release & Publish CLI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.SPEAKEASY_GITHUB_ACCESS_TOKEN }} | |
| - name: Determine version from gen.yaml | |
| id: version | |
| run: | | |
| VERSION=$(grep -A1 '^cli:' .speakeasy/gen.yaml | grep 'version:' | awk '{print $2}') | |
| echo "version=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "Detected version: v${VERSION}" | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Create and push tag | |
| run: | | |
| TAG="${{ steps.version.outputs.version }}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists, skipping" | |
| else | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push origin "$TAG" | |
| fi | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| cache: true | |
| - name: Install GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| install-only: true | |
| - name: Import GPG key | |
| uses: crazy-max/ghaction-import-gpg@v5 | |
| id: import_gpg | |
| with: | |
| gpg_private_key: ${{ secrets.CLI_GPG_SECRET_KEY }} | |
| passphrase: ${{ secrets.CLI_GPG_PASSPHRASE }} | |
| - name: Run GoReleaser | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SPEAKEASY_GITHUB_ACCESS_TOKEN }} | |
| GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | |
| GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.version }} | |
| run: goreleaser release --clean |