huaichaow is performing release on main with b43c419a9def828cf23657fa884238132d32109d π #16
This file contains 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
# reference: https://semantic-release.gitbook.io/semantic-release/recipes/ci-configurations/github-actions | |
name: Release | |
run-name: ${{ github.actor }} is performing release on ${{ github.ref_name }} with ${{ github.sha }} π | |
on: [ workflow_dispatch ] | |
permissions: | |
contents: read # for checkout | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # to be able to publish a GitHub release | |
issues: write # to be able to comment on released issues | |
pull-requests: write # to be able to comment on released pull requests | |
id-token: write # to enable use of OIDC for npm provenance | |
steps: | |
- name: Ensure the branch is 'release/main' | |
if: github.ref_name != 'release/main' | |
run: | | |
echo "release can only run on branch release/main" | |
exit 1 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies | |
run: npm audit signatures | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npx semantic-release | |
# reference: | |
# * https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request | |
# * https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api?apiVersion=2022-11-28#authentication-example-for-github-actions | |
# * https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows | |
# grant PR permission to GitHub Actions: `Allow GitHub Actions to create and approve pull requests` | |
# * https://github.com/huaichaow/marked-toc-extension/settings/actions | |
- name: Create PR to main branch | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Creating PR" | |
pr_number="$(gh api \ | |
--method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/huaichaow/marked-toc-extension/pulls \ | |
-f title='regular release' \ | |
-f body='Please pull these release!' \ | |
-f head='release/main' \ | |
-f base='main' --jq '.number')" | |
echo "Merging PR ${pr_number}" | |
gh api \ | |
--method PUT \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/huaichaow/marked-toc-extension/pulls/${pr_number}/merge \ | |
-f merge_method=rebase |