Skip to content

Commit 67c7ab3

Browse files
committed
ci(gateway): update release workflow and improve version handling
1 parent 4622c0c commit 67c7ab3

File tree

7 files changed

+125
-106
lines changed

7 files changed

+125
-106
lines changed

.github/workflows/backend-release-pr.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
- uses: actions/checkout@v5
2828
with:
2929
fetch-depth: 0
30-
# Use the app token for checkout as well
3130
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
3231
- name: git config
3332
run: |
@@ -39,7 +38,6 @@ jobs:
3938
node-version: 20
4039
cache: npm
4140

42-
# Install dependencies from root (same as frontend pipeline)
4341
- name: Install dependencies
4442
run: |
4543
npm ci || {
@@ -62,34 +60,36 @@ jobs:
6260
- name: Check for console.log in backend
6361
working-directory: services/backend
6462
run: npm run check:no-console
65-
63+
6664
- name: Prepare release
6765
working-directory: services/backend
6866
env:
6967
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
70-
TYPE_ARG: ${{ fromJSON('{"patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
7168
BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
72-
run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG
69+
TYPE_ARG: ${{ github.event.inputs.type != 'patch' && format('--increment={0}', github.event.inputs.type) || '' }}
70+
run: |
71+
# Let release-it handle version detection and incrementing properly
72+
npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG
73+
7374
- name: Update version.ts file
7475
working-directory: services/backend
7576
run: |
7677
node scripts/update-version.js
7778
git add src/config/version.ts
79+
7880
- name: get-npm-version
7981
id: package-version
8082
uses: martinbeentjes/npm-get-version-action@main
8183
with:
8284
path: services/backend
85+
8386
- name: Extract release notes
8487
id: extract-release-notes
8588
run: |
86-
# Get the current version from the package.json in the current working directory
8789
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
8890
echo "Extracting release notes for version $VERSION"
8991
90-
# Extract the changelog section for this version
9192
if [ -f CHANGELOG.md ]; then
92-
# Look for the version header and extract content until the next version or end of file
9393
RELEASE_NOTES=$(awk -v version="$VERSION" '
9494
BEGIN { found=0; content="" }
9595
/^##? [0-9]+\.[0-9]+\.[0-9]+/ {
@@ -101,10 +101,8 @@ jobs:
101101
END { print content }
102102
' CHANGELOG.md)
103103
104-
# Remove empty lines
105104
CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
106105
107-
# Save to output
108106
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
109107
echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
110108
echo "EOF" >> $GITHUB_OUTPUT
@@ -116,11 +114,11 @@ jobs:
116114
echo "release_notes=" >> $GITHUB_OUTPUT
117115
fi
118116
working-directory: services/backend
117+
119118
- name: Create pull request
120119
uses: peter-evans/create-pull-request@v7
121120
id: cpr
122121
with:
123-
# This is the key change - use the app token
124122
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
125123
branch: backend-release
126124
delete-branch: true
@@ -143,14 +141,14 @@ jobs:
143141
- `linux/amd64` (Intel/AMD)
144142
- `linux/arm64` (Apple Silicon, AWS Graviton)
145143
146-
147144
## Release notes:
148145
${{ steps.extract-release-notes.outputs.release_notes }}
149146
labels: |
150147
backend
151148
release
152149
automated pr
153150
draft: false
151+
154152
- name: Show PR link
155153
if: ${{ steps.cpr.outputs.pull-request-url }}
156154
run: |

.github/workflows/backend-release.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# Fix for .github/workflows/backend-release.yml
21
name: Backend Release
32
on:
43
pull_request:
54
types: [closed]
6-
branches:
7-
- main
5+
branches: [main]
86
paths:
97
- 'services/backend/**'
108

@@ -20,7 +18,6 @@ jobs:
2018
- uses: actions/checkout@v5
2119
with:
2220
fetch-depth: 0
23-
# Use the app token for checkout as well
2421
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
2522

2623
- name: git config
@@ -34,31 +31,27 @@ jobs:
3431
node-version: 20
3532
cache: npm
3633

37-
# Install dependencies at root level for workspaces
3834
- name: Install dependencies
3935
run: npm ci
40-
41-
# Now run release-it with the APP_INSTALLATION_TOKEN
42-
- name: Prepare release
36+
37+
- name: Create Release
4338
working-directory: services/backend
4439
env:
4540
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
46-
run: npm run release -- --ci --verbose --no-git.requireCleanWorkingDir
41+
run: |
42+
# Let release-it handle the release process properly
43+
npm run release -- --ci --verbose --no-git.requireCleanWorkingDir
4744
48-
# Get the version after release-it has run
4945
- name: Get version
5046
id: package-version
5147
uses: martinbeentjes/npm-get-version-action@main
5248
with:
5349
path: services/backend
5450

55-
# Build the backend
5651
- name: Build backend
5752
working-directory: services/backend
58-
run: |
59-
npm run build
53+
run: npm run build
6054

61-
# Prepare shared resources directory for Docker
6255
- name: Prepare shared directories
6356
run: |
6457
mkdir -p /tmp/shared

.github/workflows/frontend-release-pr.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
node-version: 20
4141
cache: npm
4242

43-
# Try normal install first, fallback to clean install only if needed
4443
- name: Install dependencies
4544
run: |
4645
npm ci || {
@@ -65,9 +64,11 @@ jobs:
6564
working-directory: services/frontend
6665
env:
6766
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
68-
TYPE_ARG: ${{ fromJSON('{"patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
6967
BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
70-
run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG
68+
TYPE_ARG: ${{ github.event.inputs.type != 'patch' && format('--increment={0}', github.event.inputs.type) || '' }}
69+
run: |
70+
# Let release-it handle version detection and incrementing properly
71+
npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG
7172
7273
- name: get-npm-version
7374
id: package-version

.github/workflows/frontend-release.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Frontend Release
22
on:
33
pull_request:
44
types: [closed]
5-
branches:
6-
- main
5+
branches: [main]
76
paths:
87
- 'services/frontend/**'
98

@@ -32,7 +31,6 @@ jobs:
3231
node-version: 20
3332
cache: npm
3433

35-
# Clean install dependencies
3634
- name: Install dependencies
3735
run: |
3836
npm ci || {
@@ -41,54 +39,45 @@ jobs:
4139
npm install --no-optional
4240
}
4341
44-
# Force install the missing rollup platform package if needed
4542
- name: Fix Rollup platform package
4643
run: |
4744
npm install @rollup/rollup-linux-x64-gnu --save-optional || echo "Rollup package already installed"
48-
49-
# Run release-it with conventional changelog
50-
- name: Prepare release
45+
46+
- name: Create Release
5147
working-directory: services/frontend
5248
env:
5349
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
54-
run: npm run release -- --ci --verbose --no-git.requireCleanWorkingDir
50+
run: |
51+
# Let release-it handle the release process properly
52+
npm run release -- --ci --verbose --no-git.requireCleanWorkingDir
5553
56-
# Get the version after release-it has run
5754
- name: Get version
5855
id: package-version
5956
uses: martinbeentjes/npm-get-version-action@main
6057
with:
6158
path: services/frontend
6259

63-
# Update .env file with version
6460
- name: Update .env with version
6561
working-directory: services/frontend
6662
run: |
67-
# If .env doesn't exist, create it
6863
if [ ! -f .env ]; then
6964
touch .env
7065
fi
7166
72-
# Check if VITE_DEPLOYSTACK_APP_VERSION already exists in .env
7367
if grep -q "VITE_DEPLOYSTACK_APP_VERSION" .env; then
74-
# Update existing env var
7568
sed -i "s/VITE_DEPLOYSTACK_APP_VERSION=.*/VITE_DEPLOYSTACK_APP_VERSION=${{ steps.package-version.outputs.current-version }}/" .env
7669
else
77-
# Add new env var
7870
echo "VITE_DEPLOYSTACK_APP_VERSION=${{ steps.package-version.outputs.current-version }}" >> .env
7971
fi
8072
81-
# Show the updated .env (without sensitive values)
8273
echo "Updated .env file:"
8374
grep VITE_DEPLOYSTACK_APP_VERSION .env
8475
85-
# Build the frontend with version env var - with rollup fix
8676
- name: Build frontend
8777
working-directory: services/frontend
8878
env:
8979
VITE_DEPLOYSTACK_APP_VERSION: ${{ steps.package-version.outputs.current-version }}
9080
run: |
91-
# Try build, if it fails due to rollup, try to fix and rebuild
9281
npm run build || {
9382
echo "Build failed, attempting rollup fix..."
9483
cd ../..
@@ -123,4 +112,4 @@ jobs:
123112
build-args: |
124113
DEPLOYSTACK_FRONTEND_VERSION=${{ steps.package-version.outputs.current-version }}
125114
cache-from: type=gha
126-
cache-to: type=gha,mode=max
115+
cache-to: type=gha,mode=max

.github/workflows/gateway-release-pr.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
- uses: actions/checkout@v5
2828
with:
2929
fetch-depth: 0
30-
# Use the app token for checkout as well
3130
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
3231
- name: git config
3332
run: |
@@ -39,7 +38,6 @@ jobs:
3938
node-version: 20
4039
cache: npm
4140

42-
# Install dependencies from root (same as backend pipeline)
4341
- name: Install dependencies
4442
run: |
4543
npm ci || {
@@ -58,41 +56,43 @@ jobs:
5856
- name: Gateway Lint
5957
working-directory: services/gateway
6058
run: npm run lint
61-
59+
6260
- name: Prepare release
6361
working-directory: services/gateway
6462
env:
6563
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
66-
TYPE_ARG: ${{ fromJSON('{"patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
6764
BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
68-
run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github --no-git.requireCleanWorkingDir $BETA_ARG
65+
TYPE_ARG: ${{ github.event.inputs.type != 'patch' && format('--increment={0}', github.event.inputs.type) || '' }}
66+
run: |
67+
# Let release-it handle version detection and incrementing properly
68+
npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github --no-git.requireCleanWorkingDir $BETA_ARG
69+
6970
- name: Stage package.json changes
7071
working-directory: services/gateway
7172
run: |
72-
# Stage the updated package.json and CHANGELOG.md
7373
git add package.json CHANGELOG.md
74+
7475
- name: Update version.ts file
7576
working-directory: services/gateway
7677
run: |
7778
node scripts/update-version.js || echo "Version update script not found, skipping"
7879
if [ -f src/config/version.ts ]; then
7980
git add src/config/version.ts
8081
fi
82+
8183
- name: get-npm-version
8284
id: package-version
8385
uses: martinbeentjes/npm-get-version-action@main
8486
with:
8587
path: services/gateway
88+
8689
- name: Extract release notes
8790
id: extract-release-notes
8891
run: |
89-
# Get the current version from the package.json in the current working directory
9092
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
9193
echo "Extracting release notes for version $VERSION"
9294
93-
# Extract the changelog section for this version
9495
if [ -f CHANGELOG.md ]; then
95-
# Look for the version header and extract content until the next version or end of file
9696
RELEASE_NOTES=$(awk -v version="$VERSION" '
9797
BEGIN { found=0; content="" }
9898
/^##? [0-9]+\.[0-9]+\.[0-9]+/ {
@@ -104,10 +104,8 @@ jobs:
104104
END { print content }
105105
' CHANGELOG.md)
106106
107-
# Remove empty lines
108107
CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
109108
110-
# Save to output
111109
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
112110
echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
113111
echo "EOF" >> $GITHUB_OUTPUT
@@ -119,11 +117,11 @@ jobs:
119117
echo "release_notes=" >> $GITHUB_OUTPUT
120118
fi
121119
working-directory: services/gateway
120+
122121
- name: Create pull request
123122
uses: peter-evans/create-pull-request@v7
124123
id: cpr
125124
with:
126-
# This is the key change - use the app token
127125
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
128126
branch: gateway-release
129127
delete-branch: true
@@ -154,6 +152,7 @@ jobs:
154152
release
155153
automated pr
156154
draft: false
155+
157156
- name: Show PR link
158157
if: ${{ steps.cpr.outputs.pull-request-url }}
159158
run: |

0 commit comments

Comments
 (0)