-
Notifications
You must be signed in to change notification settings - Fork 27
158 lines (138 loc) · 4.73 KB
/
release-agent-instructions.yml
File metadata and controls
158 lines (138 loc) · 4.73 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
name: Release hana-cli-agent-instructions
on:
push:
tags:
- 'agent-v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.202604.0). Leave empty for auto-calculation from current date.'
required: false
type: string
permissions:
contents: write
concurrency:
group: release-agent-instructions
cancel-in-progress: false
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:ci
prepare:
name: Prepare Release
needs: test
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.calc.outputs.version }}
tag: ${{ steps.calc.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Calculate version and update files
id: calc
run: |
RESULT=$(node scripts/prepare-release.js \
--package agent-instructions \
--version "${{ inputs.version }}")
VERSION=$(echo "$RESULT" | jq -r '.version')
TAG=$(echo "$RESULT" | jq -r '.tag')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Prepared release: $TAG"
- name: Configure git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit version bump
run: |
git add agent-instructions/package.json
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "chore: release agent-instructions v${{ steps.calc.outputs.version }} [skip ci]"
- name: Create and push tag
run: |
git tag -a "agent-v${{ steps.calc.outputs.version }}" -m "Release agent-instructions v${{ steps.calc.outputs.version }}"
git push origin HEAD:${{ github.ref_name }}
git push origin "agent-v${{ steps.calc.outputs.version }}"
resolve-version:
name: Resolve Version from Tag
needs: test
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
tag: ${{ github.ref_name }}
steps:
- name: Extract version from tag
id: extract
run: |
TAG="${{ github.ref_name }}"
VERSION="${TAG#agent-v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Resolved version: $VERSION from tag: $TAG"
publish:
name: Publish to npm
needs: [test, prepare, resolve-version]
if: |
always() &&
needs.test.result == 'success' &&
(needs.prepare.result == 'success' || needs.resolve-version.result == 'success')
runs-on: ubuntu-latest
steps:
- name: Determine version
id: ver
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ needs.prepare.outputs.version }}" >> $GITHUB_OUTPUT
echo "tag=${{ needs.prepare.outputs.tag }}" >> $GITHUB_OUTPUT
else
echo "version=${{ needs.resolve-version.outputs.version }}" >> $GITHUB_OUTPUT
echo "tag=${{ needs.resolve-version.outputs.tag }}" >> $GITHUB_OUTPUT
fi
- name: Checkout code at tag
uses: actions/checkout@v4
with:
ref: "agent-v${{ steps.ver.outputs.version }}"
- name: Setup Node.js with npm registry
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Publish agent-instructions to npm
working-directory: agent-instructions
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "agent-v${{ steps.ver.outputs.version }}"
name: "agent-instructions v${{ steps.ver.outputs.version }}"
body: "Release of hana-cli-agent-instructions v${{ steps.ver.outputs.version }}"
draft: false
prerelease: ${{ contains(steps.ver.outputs.version, '-') }}