6
6
type : choice
7
7
description : Choose release type
8
8
options :
9
- - auto
10
9
- patch
11
10
- minor
12
11
- major
13
- default : auto
12
+ default : patch
14
13
beta :
15
14
type : boolean
16
15
description : Prerelease
19
18
permissions :
20
19
contents : write
21
20
pull-requests : write
21
+ issues : write
22
22
23
23
jobs :
24
24
releaseIt :
@@ -30,89 +30,77 @@ jobs:
30
30
- uses : actions/checkout@v4
31
31
with :
32
32
fetch-depth : 0
33
-
33
+ # Use the app token for checkout as well
34
+ token : ${{ secrets.APP_INSTALLATION_TOKEN }}
34
35
- name : git config
35
36
run : |
36
37
git config user.name "${GITHUB_ACTOR}"
37
38
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
38
-
39
39
- name : Setup node
40
40
uses : actions/setup-node@v4
41
41
with :
42
42
node-version : 20
43
43
cache : npm
44
-
45
- # Clean install to avoid rollup issues with optional dependencies
46
- - name : Install dependencies with clean slate
47
- run : |
48
- rm -rf node_modules package-lock.json || true
49
- npm install
50
-
51
- # Determine the next version based on input
52
- - name : Get current version
53
- id : current- version
54
- run : echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
55
-
56
- - name : Determine next version
57
- id : next-version
44
+ - run : npm ci
45
+ - name : Prepare release
46
+ env :
47
+ GITHUB_TOKEN : ${{ secrets.APP_INSTALLATION_TOKEN }}
48
+ TYPE_ARG : ${{ fromJSON('{"patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
49
+ BETA_ARG : ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
50
+ run : npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG
51
+ - name : get-npm- version
52
+ id : package- version
53
+ uses : martinbeentjes/npm-get- version-action@main
54
+ with :
55
+ path : services/frontend
56
+ - name : Extract release notes
57
+ id : extract-release-notes
58
58
run : |
59
- current=${{ steps.current-version.outputs.version }}
60
- IFS='.' read -r -a version_parts <<< "$current"
61
- major=${version_parts[0]}
62
- minor=${version_parts[1]}
63
- patch=${version_parts[2]}
64
-
65
- # Determine type of version bump
66
- case "${{ github.event.inputs.type }}" in
67
- major)
68
- new_major=$((major + 1))
69
- new_version="$new_major.0.0"
70
- ;;
71
- minor)
72
- new_minor=$((minor + 1))
73
- new_version="$major.$new_minor.0"
74
- ;;
75
- patch)
76
- new_patch=$((patch + 1))
77
- new_version="$major.$minor.$new_patch"
78
- ;;
79
- auto|*)
80
- # Default to minor
81
- new_minor=$((minor + 1))
82
- new_version="$major.$new_minor.0"
83
- ;;
84
- esac
59
+ # Get the current version from the package.json in the current working directory
60
+ VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
61
+ echo "Extracting release notes for version $VERSION"
85
62
86
- # Add beta suffix if requested
87
- if [[ "${{ github.event.inputs.beta }}" == "true" ]]; then
88
- new_version="${new_version}-beta.1"
63
+ # Extract the changelog section for this version
64
+ if [ -f CHANGELOG.md ]; then
65
+ # Look for the version header and extract content until the next version or end of file
66
+ RELEASE_NOTES=$(awk -v version="$VERSION" '
67
+ BEGIN { found=0; content="" }
68
+ /^##? [0-9]+\.[0-9]+\.[0-9]+/ {
69
+ if (found) exit
70
+ if ($0 ~ version) { found=1; next }
71
+ }
72
+ found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit }
73
+ found { content = content $0 "\n" }
74
+ END { print content }
75
+ ' CHANGELOG.md)
76
+
77
+ # Clean up empty markdown links and remove empty lines
78
+ CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed 's/(\[\]([^)]*))//g' | sed '/^$/d')
79
+
80
+ # Save to output
81
+ echo "release_notes<<EOF" >> $GITHUB_OUTPUT
82
+ echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
83
+ echo "EOF" >> $GITHUB_OUTPUT
84
+
85
+ echo "Release notes extracted:"
86
+ echo "$CLEAN_NOTES"
87
+ else
88
+ echo "No CHANGELOG.md found"
89
+ echo "release_notes=" >> $GITHUB_OUTPUT
89
90
fi
90
-
91
- echo "version=$new_version" >> $GITHUB_OUTPUT
92
-
93
- # Create a temporary changelog entry
94
- - name : Generate changelog entry
95
- id : changelog
96
- run : |
97
- echo "# ${{ steps.next-version.outputs.version }} ($(date +%Y-%m-%d))" > CHANGELOG_NEW.md
98
- echo "" >> CHANGELOG_NEW.md
99
- echo "### Features" >> CHANGELOG_NEW.md
100
- echo "* Release version ${{ steps.next-version.outputs.version }}" >> CHANGELOG_NEW.md
101
- echo "" >> CHANGELOG_NEW.md
102
- cat CHANGELOG.md >> CHANGELOG_NEW.md 2>/dev/null || true
103
- cat CHANGELOG_NEW.md > TEMP_CHANGELOG.md
104
-
105
- # Create a PR with the version changes
91
+ working-directory : services/frontend
106
92
- name : Create pull request
107
93
uses : peter-evans/create-pull-request@v7
108
94
id : cpr
109
95
with :
96
+ # This is the key change - use the app token
97
+ token : ${{ secrets.APP_INSTALLATION_TOKEN }}
110
98
branch : frontend-release
111
99
delete-branch : true
112
- commit-message : ' chore(frontend): release v${{ steps.next -version.outputs.version }}'
113
- title : ' [Frontend Release] v${{ steps.next -version.outputs.version }}'
100
+ commit-message : ' chore(frontend): release v${{ steps.package -version.outputs.current- version}}'
101
+ title : ' [Frontend Release] v${{ steps.package -version.outputs.current- version}}'
114
102
body : |
115
- ## Frontend Release v${{ steps.next -version.outputs.version }}
103
+ ## Frontend Release v${{ steps.package -version.outputs.current- version}}
116
104
117
105
This PR prepares a new frontend release.
118
106
@@ -122,25 +110,24 @@ jobs:
122
110
123
111
The Docker image will be available at:
124
112
- `deploystack/frontend:latest`
125
- - `deploystack/frontend:v${{ steps.next -version.outputs.version }}`
113
+ - `deploystack/frontend:v${{ steps.package -version.outputs.current- version}}`
126
114
127
115
### Supported Architectures
128
116
- `linux/amd64` (Intel/AMD)
129
117
- `linux/arm64` (Apple Silicon, AWS Graviton)
130
118
- `linux/arm/v7` (Raspberry Pi, IoT devices)
131
119
120
+ ### Environment Variables
121
+ The Docker image will include `DEPLOYSTACK_FRONTEND_VERSION` environment variable set to the current version.
122
+
132
123
## Release notes:
133
- See attached changelog updates
124
+ ${{ steps.extract-release-notes.outputs.release_notes }}
134
125
labels : |
135
126
frontend
136
127
release
137
128
automated pr
138
129
draft : false
139
- add-paths : |
140
- services/frontend/package.json
141
- services/frontend/CHANGELOG.md
142
-
143
130
- name : Show PR link
144
131
if : ${{ steps.cpr.outputs.pull-request-url }}
145
132
run : |
146
- echo "Frontend Release v${{ steps.next -version.outputs.version }}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"
133
+ echo "Frontend Release v${{ steps.package -version.outputs.current- version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"
0 commit comments