Skip to content

ci: update release-please.yaml (#122) #37

ci: update release-please.yaml (#122)

ci: update release-please.yaml (#122) #37

on:
push:
branches:
- main
name: release-please
jobs:
release-please:
permissions:
pull-requests: write
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
## Build a release based on the release-please-config.json file
- uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
## Build go binary and add it to the release
- uses: actions/checkout@v4
with:
fetch-depth: 0
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-go@v4
with:
go-version: stable
if: ${{ steps.release.outputs.release_created }}
- name: Build go binaries
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
## Publish the release to npm
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.release_created }}
- name: Get commit author
id: commit_author
run: |
author=$(gh pr list --search ${{ github.sha }} --state merged --json mergedBy --jq '.[0].mergedBy.login')
echo "author=${author}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v3
# This sets up the .npmrc file for publishing to npm
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}
- name: Run npm publish
shell: bash
run: |
cd npm
./publish.sh
env:
NPM_TOKEN: ${{ secrets[format('NPM_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.NPM_TOKEN }}
OPTIC_TOKEN: ${{ secrets[format('OPTIC_TOKEN_{0}', steps.commit_author.outputs.author)] || secrets.OPTIC_TOKEN }}
if: ${{ steps.release.outputs.release_created }}