Skip to content

chore: add -y/--yes flag to skip interactive prompt (#1525) #1149

chore: add -y/--yes flag to skip interactive prompt (#1525)

chore: add -y/--yes flag to skip interactive prompt (#1525) #1149

Workflow file for this run

name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
# We have setup NPM trusted publishing which requires running the release
# workflow on GitHub-hosted runners. It can running on ubicloud or any other
# self-hosted runners that we manage.
# https://docs.npmjs.com/trusted-publishers
runs-on: ubuntu-latest
permissions:
contents: write # to push tags
pull-requests: read
issues: read
id-token: write # to publish to NPM
outputs:
published: ${{ steps.changesets.outputs.published }}
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
env:
GRAM_GIT_SHA: "${{ github.sha }}"
steps:
- name: Checkout Repo
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0
- name: Setup Mise
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
with:
install: true
cache: true
env: false
- name: Prepare GitHub Actions environment
run: mise run github
- name: Cache PNPM
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
key: ${{ env.GH_CACHE_PNPM_KEY }}
restore-keys: |
${{ env.GH_CACHE_PNPM_KEY }}
${{ env.GH_CACHE_PNPM_KEY_PARTIAL }}
path: |
${{ env.PNPM_STORE_PATH }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@b96fde71c0080358ed6e2d162f11c612c92a97d1 # v2.1.4
with:
app-id: ${{ vars.GRAM_BOT_APP_ID }}
private-key: ${{ secrets.GRAM_BOT_PRIVATE_KEY }}
# Configure git to commit as the GitHub App so commits trigger workflows.
# Commits from github-actions[bot] don't trigger workflows by design.
- name: Configure git for GitHub App
run: |
git config user.name "gram-bot[bot]"
git config user.email "gram-bot[bot]@users.noreply.github.com"
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@c48e67d110a68bc90ccf1098e9646092baacaa87 # v1.6.0
with:
title: "chore: version packages"
publish: mise exec --env viteprod -- pnpm changeset publish
setupGitUser: false
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
# Datadog RUM credentials for @gram-ai/elements error tracking
VITE_DATADOG_APPLICATION_ID: ${{ secrets.VITE_DATADOG_APPLICATION_ID }}
VITE_DATADOG_CLIENT_TOKEN: ${{ secrets.VITE_DATADOG_CLIENT_TOKEN }}
VITE_DATADOG_SITE: ${{ secrets.VITE_DATADOG_SITE }}
- name: Prune PNPM store
run: pnpm store prune
release-cli:
needs: [release]
if: needs.release.outputs.published == 'true' && contains(fromJSON(needs.release.outputs.publishedPackages).*.name, 'cli')
name: Release Gram CLI
# NOTE(cjea): Using Windows runner for future Chocolatey/Winget
# compatibility.
runs-on: windows-latest
permissions:
contents: write # to push tags
id-token: write # for cosign keyless signing
steps:
- name: Setup environment
run: |-
chcp 65001 #set code page to utf-8
- name: Checkout repository
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v5.0.0
with:
fetch-depth: 0
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: "go.mod"
# Reference: https://github.com/actions/setup-go/issues/495
cache: false
- name: Setup Choco
uses: crazy-max/ghaction-chocolatey@2526f467ccbd337d307fe179959cabbeca0bc8c0 # v3.4.0
with:
args: --version
- name: Install cosign
uses: sigstore/cosign-installer@fb28c2b6339dcd94da6e4cbcbc5e888961f6f8c3 # v3.9.0
- name: Generate GitHub App Token for Gram Bot
id: bot-token
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
with:
app-id: ${{ secrets.GRAM_BOT_APP_ID }}
private-key: ${{ secrets.GRAM_BOT_PRIVATE_KEY }}
owner: speakeasy-api
repositories: gram,homebrew-tap
- name: Create release tag
# GoReleaser expects a tag on HEAD before releasing. The newest tag
# will be on an old commit, specified by `changeset`, so this is a
# local-only tag to help GoReleaser publish.
shell: pwsh
run: |
$version = (Get-Content cli/package.json | ConvertFrom-Json).version
$tag = "cli/$version"
git tag -f $tag
Write-Host "Created local tag $tag"
- name: goreleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser-pro
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }}
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
GORELEASER_KEY: ${{secrets.GORELEASER_PRO_LICENSE_KEY}}