ci: test conditional running of xgo and release #26
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 | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| release: | |
| permissions: | |
| contents: write # to create release (changesets/action) | |
| pull-requests: write # to create pull request (changesets/action) | |
| name: Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun install | |
| - name: Check for changesets | |
| id: check | |
| run: | | |
| if bunx changeset status --since=main --verbose | grep -q 'Packages to be bumped'; then | |
| echo "CHANGESETS_PENDING=true" >> $GITHUB_ENV | |
| else | |
| echo "CHANGESETS_PENDING=false" >> $GITHUB_ENV | |
| fi | |
| - name: Build with xgo | |
| uses: crazy-max/ghaction-xgo@v3 | |
| if: env.CHANGESETS_PENDING == 'true' | |
| with: | |
| go_version: latest | |
| targets: windows/amd64,linux/amd64,linux/arm64,darwin/arm64 | |
| dest: release # Output directory for binaries | |
| prefix: blipgloss | |
| # Add other xgo flags as needed, e.g.: | |
| ldflags: -s -w | |
| buildmode: c-shared | |
| - name: Create Release Pull Request or Publish to npm | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| publish: bun run release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |