Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regular release #10

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Integration
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
run-name: ${{ github.actor }} is testing on ${{ github.ref_name }} with ${{ github.sha }}
on: [ push ]

concurrency:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 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:
Expand All @@ -16,6 +17,12 @@ jobs:
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:
Expand All @@ -37,3 +44,34 @@ jobs:
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