66 type : choice
77 description : Choose release type
88 options :
9- - auto
109 - patch
1110 - minor
1211 - major
13- default : auto
12+ default : patch
1413 beta :
1514 type : boolean
1615 description : Prerelease
1918permissions :
2019 contents : write
2120 pull-requests : write
21+ issues : write
2222
2323jobs :
2424 releaseIt :
@@ -30,89 +30,77 @@ jobs:
3030 - uses : actions/checkout@v4
3131 with :
3232 fetch-depth : 0
33-
33+ # Use the app token for checkout as well
34+ token : ${{ secrets.APP_INSTALLATION_TOKEN }}
3435 - name : git config
3536 run : |
3637 git config user.name "${GITHUB_ACTOR}"
3738 git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
38-
3939 - name : Setup node
4040 uses : actions/setup-node@v4
4141 with :
4242 node-version : 20
4343 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
5858 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"
8562
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
8990 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
10692 - name : Create pull request
10793 uses : peter-evans/create-pull-request@v7
10894 id : cpr
10995 with :
96+ # This is the key change - use the app token
97+ token : ${{ secrets.APP_INSTALLATION_TOKEN }}
11098 branch : frontend-release
11199 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}}'
114102 body : |
115- ## Frontend Release v${{ steps.next -version.outputs.version }}
103+ ## Frontend Release v${{ steps.package -version.outputs.current- version}}
116104
117105 This PR prepares a new frontend release.
118106
@@ -122,25 +110,24 @@ jobs:
122110
123111 The Docker image will be available at:
124112 - `deploystack/frontend:latest`
125- - `deploystack/frontend:v${{ steps.next -version.outputs.version }}`
113+ - `deploystack/frontend:v${{ steps.package -version.outputs.current- version}}`
126114
127115 ### Supported Architectures
128116 - `linux/amd64` (Intel/AMD)
129117 - `linux/arm64` (Apple Silicon, AWS Graviton)
130118 - `linux/arm/v7` (Raspberry Pi, IoT devices)
131119
120+ ### Environment Variables
121+ The Docker image will include `DEPLOYSTACK_FRONTEND_VERSION` environment variable set to the current version.
122+
132123 ## Release notes:
133- See attached changelog updates
124+ ${{ steps.extract-release-notes.outputs.release_notes }}
134125 labels : |
135126 frontend
136127 release
137128 automated pr
138129 draft : false
139- add-paths : |
140- services/frontend/package.json
141- services/frontend/CHANGELOG.md
142-
143130 - name : Show PR link
144131 if : ${{ steps.cpr.outputs.pull-request-url }}
145132 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