-
Notifications
You must be signed in to change notification settings - Fork 4
159 lines (137 loc) · 5.34 KB
/
Copy pathgateway-release-pr.yml
File metadata and controls
159 lines (137 loc) · 5.34 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Gateway Release PR
on:
workflow_dispatch:
inputs:
type:
type: choice
description: Choose release type
options:
- patch
- minor
- major
default: patch
beta:
type: boolean
description: Prerelease
default: false
permissions:
contents: write
pull-requests: write
issues: write
jobs:
releaseIt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: |
npm ci || {
echo "npm ci failed, trying clean install..."
npm install --no-optional
}
- name: Gateway Build Test
working-directory: services/gateway
run: npm run build
- name: Gateway Unit Tests
working-directory: services/gateway
run: npm run test:unit || echo "Tests not implemented yet, skipping"
- name: Gateway Lint
working-directory: services/gateway
run: npm run lint
- name: Prepare release
working-directory: services/gateway
env:
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
TYPE_ARG: ${{ github.event.inputs.type != 'patch' && format('--increment={0}', github.event.inputs.type) || '' }}
run: |
# Let release-it handle version detection and incrementing properly
npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github --no-git.requireCleanWorkingDir $BETA_ARG
- name: Stage package.json changes
working-directory: services/gateway
run: |
git add package.json CHANGELOG.md
- name: Update version.ts file
working-directory: services/gateway
run: |
node scripts/update-version.js || echo "Version update script not found, skipping"
if [ -f src/config/version.ts ]; then
git add src/config/version.ts
fi
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: services/gateway
- name: Extract release notes
id: extract-release-notes
run: |
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
echo "Extracting release notes for version $VERSION"
if [ -f CHANGELOG.md ]; then
RELEASE_NOTES=$(awk -v version="$VERSION" '
BEGIN { found=0; content="" }
/^##? [0-9]+\.[0-9]+\.[0-9]+/ {
if (found) exit
if ($0 ~ version) { found=1; next }
}
found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit }
found { content = content $0 "\n" }
END { print content }
' CHANGELOG.md)
CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Release notes extracted:"
echo "$CLEAN_NOTES"
else
echo "No CHANGELOG.md found"
echo "release_notes=" >> $GITHUB_OUTPUT
fi
working-directory: services/gateway
- name: Create pull request
uses: peter-evans/create-pull-request@v7
id: cpr
with:
token: ${{ secrets.APP_INSTALLATION_TOKEN }}
branch: gateway-release
delete-branch: true
commit-message: 'chore(gateway): release v${{ steps.package-version.outputs.current-version}}'
title: '[Gateway Release] v${{ steps.package-version.outputs.current-version}}'
body: |
## Gateway Release v${{ steps.package-version.outputs.current-version}}
This PR prepares a new gateway release.
When merged, this will:
1. Create a release tag
2. Build and publish the npm package to @deploystack/gateway
The npm package will be available at:
- `@deploystack/gateway@latest`
- `@deploystack/gateway@v${{ steps.package-version.outputs.current-version}}`
### Installation
```bash
npm install -g @deploystack/gateway@${{ steps.package-version.outputs.current-version}}
```
## Release notes:
${{ steps.extract-release-notes.outputs.release_notes }}
labels: |
gateway
release
automated pr
draft: false
- name: Show PR link
if: ${{ steps.cpr.outputs.pull-request-url }}
run: |
echo "Gateway Release v${{ steps.package-version.outputs.current-version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"