Skip to content

Commit 535b12b

Browse files
Create release.yml
1 parent f12221e commit 535b12b

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Create release
2+
run-name: ${{ format('Create {0} release', inputs.version_type) }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version_type:
8+
description: "Version type"
9+
required: true
10+
default: "patch"
11+
type: choice
12+
options:
13+
- patch
14+
- minor
15+
- major
16+
17+
jobs:
18+
publish:
19+
name: Publish release
20+
runs-on: ubuntu-latest
21+
permissions:
22+
id-token: write
23+
contents: write
24+
25+
steps:
26+
- name: Exit early if not on 1.x
27+
if: github.ref != 'refs/heads/1.x'
28+
run: exit 1
29+
30+
- uses: actions/create-github-app-token@v1
31+
id: app-token
32+
with:
33+
app-id: ${{ vars.NIGHTWATCH_PERMISSIONS_APP_ID }}
34+
private-key: ${{ secrets.NIGHTWATCH_PERMISSIONS_APP_PRIVATE_KEY }}
35+
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
with:
39+
token: ${{ steps.app-token.outputs.token }}
40+
41+
- name: Bump version
42+
shell: bash
43+
id: bump-version
44+
run: |
45+
IFS="."
46+
version_type=${{ inputs.version_type }}
47+
current_version=$(cat version.txt)
48+
49+
if [[ $current_version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
50+
major=${BASH_REMATCH[1]}
51+
minor=${BASH_REMATCH[2]}
52+
patch=${BASH_REMATCH[3]}
53+
54+
case "$version_type" in
55+
major)
56+
major=$((major + 1))
57+
minor=0
58+
patch=0
59+
;;
60+
minor)
61+
minor=$((minor + 1))
62+
patch=0
63+
;;
64+
patch)
65+
patch=$((patch + 1))
66+
;;
67+
esac
68+
69+
echo "Bumping ${version_type} version"
70+
echo "Was: ${current_version}"
71+
72+
new_version="$major.$minor.$patch"
73+
echo "version=$new_version" >> "$GITHUB_OUTPUT"
74+
echo "Now: ${new_version}"
75+
echo "${new_version}" > version.txt
76+
else
77+
echo "Current version format is invalid" >&2
78+
exit 1
79+
fi
80+
81+
- uses: EndBug/add-and-commit@v9
82+
with:
83+
default_author: github_actions
84+
message: "Bump version to v${{ steps.bump-version.outputs.version }}"
85+
tag: "v${{ steps.bump-version.outputs.version }}"
86+
push: true
87+
88+
- name: Generate release notes
89+
id: notes
90+
uses: RedCrafter07/release-notes-action@main
91+
with:
92+
tag-name: v${{ steps.bump-version.outputs.version }}
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
branch: "1.x"
95+
96+
- name: Update Changelog
97+
uses: stefanzweifel/changelog-updater-action@v1
98+
with:
99+
release-notes: ${{ steps.notes.outputs.release-notes }}
100+
latest-version: "v${{ github.event.release.tag_name }}"
101+
compare-url-target-revision: "1.x"
102+
parse-github-usernames: true
103+
104+
- uses: softprops/action-gh-release@v2
105+
with:
106+
generate_release_notes: false
107+
body: ${{ steps.notes.outputs.release-notes }}
108+
make_latest: true
109+
name: "v${{ steps.bump-version.outputs.version }}"
110+
tag_name: "v${{ steps.bump-version.outputs.version }}"

0 commit comments

Comments
 (0)