-
Notifications
You must be signed in to change notification settings - Fork 4
134 lines (123 loc) · 5.08 KB
/
Copy pathgateway-release.yml
File metadata and controls
134 lines (123 loc) · 5.08 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
name: Gateway Release
on:
pull_request:
types: [closed]
branches: [main]
paths:
- 'services/gateway/**'
permissions:
contents: write
packages: write
issues: write
jobs:
release:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'gateway') && contains(github.event.pull_request.labels.*.name, 'release')
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
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
npm ci || {
echo "npm ci failed, trying clean install..."
npm install --no-optional
}
- name: Gateway Build
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: Create Release
working-directory: services/gateway
env:
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Let release-it handle the release process properly
npm run release -- --ci --verbose --no-git.requireCleanWorkingDir
- name: Publish to NPM
working-directory: services/gateway
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Publish the built package to NPM
npm publish --access public
- name: Get 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"
# Find the latest gateway tag (excluding the current one)
LATEST_TAG=$(git tag --list "gateway-v*" --sort=-version:refname | grep -v "gateway-v${VERSION}" | head -1)
if [ -z "$LATEST_TAG" ]; then
echo "No previous gateway tag found, using all commits"
GATEWAY_COMMITS=$(git log --oneline --grep="(gateway)" --grep="(all)" --grep-or)
else
echo "Using commits since $LATEST_TAG"
# Get gateway and all scoped commits since last release
GATEWAY_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(gateway)")
ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
# Combine and format the commits
COMBINED_COMMITS=$(echo -e "$GATEWAY_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
fi
# Format commits for release notes
if [ -n "$COMBINED_COMMITS" ]; then
RELEASE_NOTES=""
while IFS= read -r commit; do
if [ -n "$commit" ]; then
# Extract commit hash and message
HASH=$(echo "$commit" | cut -d' ' -f1)
MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
fi
done <<< "$COMBINED_COMMITS"
else
RELEASE_NOTES="No significant changes since last release."
fi
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "Release notes extracted:"
echo -e "$RELEASE_NOTES"
working-directory: services/gateway
- name: Update GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: gateway-v${{ steps.package-version.outputs.current-version }}
name: Gateway v${{ steps.package-version.outputs.current-version }}
body: |
## Gateway Release v${{ steps.package-version.outputs.current-version }}
The npm package is 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 }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.APP_INSTALLATION_TOKEN }}