|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + name: Release |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: read |
| 17 | + issues: read |
| 18 | + id-token: write |
| 19 | + outputs: |
| 20 | + published: ${{ steps.changesets.outputs.published }} |
| 21 | + publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} |
| 22 | + steps: |
| 23 | + - name: Checkout Repo |
| 24 | + uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 |
| 25 | + |
| 26 | + - name: Setup PNPM |
| 27 | + uses: pnpm/action-setup@7088e561eb65bb68695d245aa206f005ef30921d # v4.1.0 |
| 28 | + with: |
| 29 | + run_install: false |
| 30 | + |
| 31 | + - name: Setup Node |
| 32 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 33 | + with: |
| 34 | + node-version: 24 |
| 35 | + cache: pnpm |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: pnpm install --frozen-lockfile |
| 39 | + |
| 40 | + - name: Generate a token |
| 41 | + id: generate-token |
| 42 | + uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 |
| 43 | + with: |
| 44 | + app-id: ${{ vars.GRAM_BOT_APP_ID }} |
| 45 | + private-key: ${{ secrets.GRAM_BOT_PRIVATE_KEY }} |
| 46 | + |
| 47 | + - name: Configure git for GitHub App |
| 48 | + run: | |
| 49 | + git config user.name "speakeasy-bot[bot]" |
| 50 | + git config user.email "speakeasy-bot[bot]@users.noreply.github.com" |
| 51 | +
|
| 52 | + - name: Create Release Pull Request or Publish to npm |
| 53 | + id: changesets |
| 54 | + uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1.7.0 |
| 55 | + with: |
| 56 | + title: "chore: version packages" |
| 57 | + publish: pnpm changeset publish |
| 58 | + setupGitUser: false |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
| 61 | + |
| 62 | + - name: Prune PNPM store |
| 63 | + run: pnpm store prune |
| 64 | + |
| 65 | + release-cli: |
| 66 | + needs: [release] |
| 67 | + if: needs.release.outputs.published == 'true' && contains(fromJSON(needs.release.outputs.publishedPackages).*.name, 'cli') |
| 68 | + name: Release Speakeasy CLI |
| 69 | + runs-on: ubuntu-latest |
| 70 | + permissions: |
| 71 | + contents: write |
| 72 | + id-token: write |
| 73 | + steps: |
| 74 | + - name: Checkout repository |
| 75 | + uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0 |
| 76 | + with: |
| 77 | + fetch-depth: 0 |
| 78 | + |
| 79 | + - name: Setup Go |
| 80 | + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 |
| 81 | + with: |
| 82 | + go-version-file: go/cli/go.mod |
| 83 | + cache: false |
| 84 | + |
| 85 | + - name: Install cosign |
| 86 | + uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1 |
| 87 | + |
| 88 | + - name: Generate GitHub App Token for Speakeasy Bot |
| 89 | + id: bot-token |
| 90 | + uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 |
| 91 | + with: |
| 92 | + app-id: ${{ secrets.GRAM_BOT_APP_ID }} |
| 93 | + private-key: ${{ secrets.GRAM_BOT_PRIVATE_KEY }} |
| 94 | + owner: speakeasy-api |
| 95 | + repositories: gf,homebrew-tap |
| 96 | + |
| 97 | + - name: Create release tag |
| 98 | + run: | |
| 99 | + version=$(jq -r .version go/cli/package.json) |
| 100 | + tag="cli@$version" |
| 101 | + git tag -f "$tag" |
| 102 | + echo "Created local tag $tag" |
| 103 | +
|
| 104 | + - name: GoReleaser |
| 105 | + uses: goreleaser/goreleaser-action@1a80836c5c9d9e5755a25cb59ec6f45a3b5f41a8 # v7.2.1 |
| 106 | + with: |
| 107 | + distribution: goreleaser-pro |
| 108 | + version: "~> v2.14" |
| 109 | + args: release --clean |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }} |
| 112 | + GORELEASER_KEY: ${{ secrets.GORELEASER_PRO_LICENSE_KEY }} |
0 commit comments