Skip to content

Commit cf92c09

Browse files
committed
chore: split release pipeline into prep & release
1 parent a051f45 commit cf92c09

File tree

2 files changed

+93
-40
lines changed

2 files changed

+93
-40
lines changed

.github/workflows/release.yml renamed to .github/workflows/prep-release.yml

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
12
---
2-
name: Release
3+
name: Prepare Release
34

45
on:
56
workflow_dispatch:
@@ -33,7 +34,7 @@ jobs:
3334
permissions: write-all
3435
runs-on: ubuntu-latest
3536
if: github.repository_owner == 'fabric8-analytics'
36-
name: Create a release
37+
name: Prepare a release
3738
environment: production
3839

3940
steps:
@@ -151,7 +152,7 @@ jobs:
151152
gh label create "${{ steps.bump.outputs.version }}" --force
152153
gh pr create \
153154
--base main \
154-
--title "Release ${{ steps.bump.outputs.version }}" \
155+
--title "[release] ${{ steps.bump.outputs.version }}" \
155156
--body "$PR_BODY" \
156157
--head release/${{ steps.bump.outputs.version }} \
157158
--label "release" --label "${{ steps.bump.outputs.version }}"
@@ -165,40 +166,4 @@ jobs:
165166
- Updated version in package.json
166167
- Updated changelog
167168
168-
- name: Create a release
169-
id: new_release
170-
uses: actions/github-script@v7
171-
with:
172-
github-token: ${{ secrets.GITHUB_TOKEN }}
173-
script: |
174-
const repo_name = context.payload.repository.full_name
175-
const response = await github.request('POST /repos/' + repo_name + '/releases', {
176-
tag_name: '${{ steps.bump.outputs.version }}',
177-
name: '${{ steps.bump.outputs.version }}',
178-
body: '${{ steps.release-notes.outputs.notes }}',
179-
prerelease: false,
180-
generate_release_notes: true
181-
})
182-
core.setOutput('upload_url', response.data.upload_url)
183-
184-
- name: Upload packages and checksums as release assets
185-
run: |
186-
for file in fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix*
187-
do
188-
asset_name=$(basename "$file")
189-
upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g")
190-
curl --data-binary @"$file" \
191-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
192-
-H "Content-Type: application/octet-stream" \
193-
"$upload_url"
194-
done
195-
196-
- name: Publish to VSCode Marketplace
197-
if: ${{ github.event.inputs.publishToMarketplace == 'true' }}
198-
run: |
199-
vsce publish --pat ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix ${{ github.event.inputs.publishPreRelease == 'true' && '--pre-release' || '' }}
200-
201-
- name: Publish to Open VSX Registry
202-
if: ${{ github.event.inputs.publishToOVSX == 'true' }}
203-
run: |
204-
npx ovsx publish --pat ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix ${{ github.event.inputs.publishPreRelease == 'true' && '--pre-release' || '' }}
169+

.github/workflows/release.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
---
3+
name: Release
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
release:
13+
permissions: write-all
14+
runs-on: ubuntu-latest
15+
if: "github.repository_owner == 'fabric8-analytics' && startsWith(github.event.head_commit.message, '[release]')"
16+
name: Create & publish a release
17+
environment: production
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
ssh-key: ${{ secrets.DEPLOY_KEY }}
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
registry-url: 'https://npm.pkg.github.com'
30+
env:
31+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Create .npmrc
34+
run: |
35+
echo "@trustification:registry=https://npm.pkg.github.com" > ~/.npmrc
36+
echo "@fabric8-analytics:registry=https://npm.pkg.github.com" >> ~/.npmrc
37+
38+
- name: Install @vscode/vsce
39+
run: npm i -g @vscode/vsce
40+
41+
- name: Install Dependencies
42+
run: npm ci
43+
44+
- name: VSCE package
45+
run: vsce package --out fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix
46+
47+
- name: Create SHA256 checksum
48+
run: |
49+
sha256sum fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix > fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix.sha256
50+
51+
- name: Create a release
52+
id: new_release
53+
uses: actions/github-script@v7
54+
with:
55+
github-token: ${{ secrets.GITHUB_TOKEN }}
56+
script: |
57+
const repo_name = context.payload.repository.full_name
58+
const response = await github.request('POST /repos/' + repo_name + '/releases', {
59+
tag_name: '${{ steps.bump.outputs.version }}',
60+
name: '${{ steps.bump.outputs.version }}',
61+
body: '${{ steps.release-notes.outputs.notes }}',
62+
prerelease: false,
63+
generate_release_notes: true
64+
})
65+
core.setOutput('upload_url', response.data.upload_url)
66+
67+
- name: Upload packages and checksums as release assets
68+
run: |
69+
for file in fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix*
70+
do
71+
asset_name=$(basename "$file")
72+
upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g")
73+
curl --data-binary @"$file" \
74+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
75+
-H "Content-Type: application/octet-stream" \
76+
"$upload_url"
77+
done
78+
79+
- name: Publish to VSCode Marketplace
80+
if: ${{ github.event.inputs.publishToMarketplace == 'true' }}
81+
run: |
82+
vsce publish --pat ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix ${{ github.event.inputs.publishPreRelease == 'true' && '--pre-release' || '' }}
83+
84+
- name: Publish to Open VSX Registry
85+
if: ${{ github.event.inputs.publishToOVSX == 'true' }}
86+
run: |
87+
npx ovsx publish --pat ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath fabric8-analytics-${{ steps.bump.outputs.version }}-${{ github.run_number }}.vsix ${{ github.event.inputs.publishPreRelease == 'true' && '--pre-release' || '' }}
88+

0 commit comments

Comments
 (0)