-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (66 loc) · 2.23 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 }}
permissions:
contents: write
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: Create branch
run: |
git switch -c ${{ env.PR_BRANCH }}
- 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"
git push --set-upstream origin ${{ env.PR_BRANCH }}
- name: Create PR
run: |
gh pr create \
--base master \
--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: ${{ github.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 }}