-
Notifications
You must be signed in to change notification settings - Fork 25
164 lines (145 loc) · 5.31 KB
/
patch-release.yml
File metadata and controls
164 lines (145 loc) · 5.31 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
160
161
162
163
164
name: Patch Release
on:
workflow_dispatch:
inputs:
branch:
description: "Release branch (e.g., release-0.4)"
required: true
type: string
dry_run:
description: "Preview actions without making changes"
required: false
type: boolean
default: false
skip_vscode_publish:
description: "Skip publishing to VS Code Marketplace"
required: false
type: boolean
default: false
skip_openvsx_publish:
description: "Skip publishing to Open VSX"
required: false
type: boolean
default: false
env:
HUSKY: 0
jobs:
compute-version:
name: Compute Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.calc.outputs.version }}
tag: ${{ steps.calc.outputs.tag }}
has_changes: ${{ steps.calc.outputs.has_changes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 0
- name: Compute base version
id: base
run: |
BASE=$(echo "${{ inputs.branch }}" | sed 's/release-//')
echo "base_version=$BASE" >> "$GITHUB_OUTPUT"
- name: Compute next version
id: calc
uses: ./.github/actions/compute-version
with:
base_version: ${{ steps.base.outputs.base_version }}
- name: Skip summary
if: steps.calc.outputs.has_changes != 'true'
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## Patch Release Skipped
No new commits on \`${{ inputs.branch }}\` since \`${{ steps.calc.outputs.prev_tag }}\`.
EOF
- name: Dry run summary
if: inputs.dry_run && steps.calc.outputs.has_changes == 'true'
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## [DRY RUN] Patch Release
**Tag:** \`${{ steps.calc.outputs.tag }}\`
**Branch:** \`${{ inputs.branch }}\`
No changes made.
EOF
release:
name: Release
needs: compute-version
if: >-
needs.compute-version.outputs.has_changes == 'true'
&& !inputs.dry_run
uses: ./.github/workflows/release.yml
with:
version: ${{ needs.compute-version.outputs.version }}
tag: ${{ needs.compute-version.outputs.tag }}
prerelease: false
ref: ${{ inputs.branch }}
skip_vscode_publish: ${{ inputs.skip_vscode_publish }}
skip_openvsx_publish: ${{ inputs.skip_openvsx_publish }}
secrets: inherit
housekeeping:
name: Assemble Changelog
runs-on: ubuntu-latest
needs: [compute-version, release]
if: ${{ !inputs.dry_run && needs.compute-version.outputs.has_changes == 'true' }}
steps:
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 0
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v3
with:
application_id: ${{ vars.KONVEYOR_BOT_ID }}
application_private_key: ${{ secrets.KONVEYOR_BOT_KEY }}
- name: Configure git
run: |
git config user.name "konveyor-bot"
git config user.email "konveyor-bot@users.noreply.github.com"
git remote set-url origin \
"https://x-access-token:${{ steps.get_workflow_token.outputs.token }}@github.com/${{ github.repository }}.git"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Assemble changelog
run: |
npm run changelog:assemble -- "${{ needs.compute-version.outputs.tag }}"
git add -A
if ! git diff --cached --quiet; then
git commit -m "assemble changelog for ${{ needs.compute-version.outputs.tag }}"
git push origin ${{ inputs.branch }}
else
echo "No changelog fragments to assemble"
fi
- name: Summary
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
## Post-Release Housekeeping
| Step | Result |
|------|--------|
| Changelog | assembled on \`${{ inputs.branch }}\` |
| Tag | \`${{ needs.compute-version.outputs.tag }}\` |
EOF
report_failure:
name: Report Failure
needs: [compute-version, release, housekeeping]
if: ${{ always() && contains(needs.*.result, 'failure') }}
runs-on: ubuntu-latest
steps:
- name: Send failure to Slack
uses: slackapi/slack-github-action@v1.26.0
with:
payload: |
{
"text": "Patch Release Failed\n\nBranch: ${{ inputs.branch }}\nPlanned tag: ${{ needs.compute-version.outputs.tag }}\nVersion: ${{ needs.compute-version.outputs.version }}\nRun: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n\nJobs:\n• compute-version: ${{ needs.compute-version.result }}\n• release: ${{ needs.release.result }}\n• housekeeping: ${{ needs.housekeeping.result }}",
"branch": "${{ inputs.branch }}",
"note": "Failed run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.INTERNAL_SLACK_WEBHOOK_URL }}