-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Publish a release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
required: true | ||
type: choice | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
env: | ||
PR_BRANCH: release-ci-${{ github.sha }} | ||
|
||
jobs: | ||
|
||
prepare_metadata: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.bump_version.outputs.version }} | ||
release_sha: ${{ steps.merge_pr.outputs.sha }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up git | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Jan Buchar" | ||
- name: Bump version in package.json | ||
id: bump_version | ||
run: | | ||
npm version ${{ github.event.inputs.release_type }} | ||
echo version=$( node -p "require('./package.json').version" ) >> "$GITHUB_OUTPUT" | ||
- name: Create PR | ||
run: | | ||
git switch -c ${{ env.PR_BRANCH }} | ||
gh pr create \ | ||
--base main \ | ||
--head ${{ env.PR_BRANCH }} \ | ||
--title "chore: Release ${{ steps.bump_version.outputs.version }} [skip-ci]" \ | ||
--body "Automated pull request - update to ${{ steps.bump_version.outputs.version }}" | ||
env: | ||
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | ||
- name: Approve and merge PR | ||
id: merge_pr | ||
run: | | ||
gh pr review --approve ${{ env.PR_BRANCH }} | ||
gh pr merge --squash --auto --delete-branch ${{ env.PR_BRANCH }} | ||
echo sha=$( gh pr view --json mergeCommit ${{ env.PR_BRANCH }} | jq --raw-output .mergeCommit.oid ) >> "$GITHUB_OUTPUT" | ||
env: | ||
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }} | ||
|
||
gh_release: | ||
runs-on: ubuntu-latest | ||
needs: prepare_metadata | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Create release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: release-${{ needs.prepare_metadata.outputs.version }} | ||
name: Release ${{ needs.prepare_metadata.outputs.version }} | ||
target_commitish: ${{ needs.prepare_metadata.outputs.release_sha }} |