Skip to content

Commit 4011064

Browse files
committed
build(ci): create a PR with new release
Signed-off-by: Ruben Romero Montes <[email protected]> Assisted-by: Cursor
1 parent bbefc3f commit 4011064

File tree

2 files changed

+28
-46
lines changed

2 files changed

+28
-46
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ on:
1414
- major
1515

1616
jobs:
17-
build:
17+
release:
18+
permissions: write-all
1819
runs-on: ubuntu-latest
1920
if: github.repository_owner == 'fabric8-analytics'
20-
name: Build plugin
21+
name: Create a release
22+
environment: production
2123

2224
steps:
2325
- name: Checkout repository
@@ -47,32 +49,18 @@ jobs:
4749
- name: Update package with new version
4850
id: bump
4951
run: |
50-
echo "version=$(npm version ${{ github.event.inputs.version_bump }} --no-git-tag-version)" >> "$GITHUB_OUTPUT"
52+
new_version=$(npm version ${{ github.event.inputs.version_bump }} --no-git-tag-version)
53+
echo "version=$new_version" >> "$GITHUB_OUTPUT"
5154
5255
- name: Compile for test
5356
run: npm run test-compile
5457

5558
- name: VSCE package
5659
run: vsce package --out fabric8-analytics-${{ steps.bump.outputs.version }}.vsix
5760

58-
- name: Upload vsix package as artifact
59-
uses: actions/upload-artifact@v4
60-
with:
61-
name: vsix
62-
path: ./fabric8-analytics-${{ steps.bump.outputs.version }}.vsix
63-
64-
release:
65-
permissions: write-all
66-
runs-on: ubuntu-latest
67-
name: Create a release
68-
environment: production
69-
needs: build
70-
71-
steps:
72-
- name: Checkout sources
73-
uses: actions/checkout@v4
74-
with:
75-
ssh-key: ${{ secrets.DEPLOY_KEY }}
61+
- name: Create SHA256 checksum
62+
run: |
63+
sha256sum fabric8-analytics-${{ steps.bump.outputs.version }}.vsix > fabric8-analytics-${{ steps.bump.outputs.version }}.vsix.sha256
7664
7765
- name: Configure git
7866
run: |
@@ -81,12 +69,12 @@ jobs:
8169
8270
- name: Create release branch
8371
run: |
84-
git checkout -b release/${{ needs.build.outputs.version }}
72+
git checkout -b release/${{ steps.bump.outputs.version }}
8573
8674
- name: Create release notes from changelog
8775
id: release-notes
8876
run: |
89-
version="${{ needs.build.outputs.version }}"
77+
version="${{ steps.bump.outputs.version }}"
9078
version=${version#v}
9179
notes=$(echo -e "## Changelog\n$(sed -n "/## $version/,/^##/p" ./CHANGELOG.md | grep -v '##')")
9280
if [ -z "$notes" ]; then
@@ -119,7 +107,7 @@ jobs:
119107
fi
120108
121109
today="$(date +"%b %-d")$suffix $(date +"%Y")"
122-
version="${{ needs.build.outputs.version }}"
110+
version="${{ steps.bump.outputs.version }}"
123111
124112
if grep -qE "## $version \([^)]*\)" ./CHANGELOG.md; then
125113
current_date=$(grep -oP "(?<=## $version \()[^\)]*" ./CHANGELOG.md)
@@ -132,39 +120,34 @@ jobs:
132120
sed -E -i "s/## $version/## $version ($today)/" CHANGELOG.md
133121
fi
134122
135-
- name: Download vsix package artifact
136-
uses: actions/download-artifact@v4
137-
with:
138-
name: vsix
139-
path: ./vsix
140-
141123
- name: Commit changes
142124
run: |
143125
git add CHANGELOG.md
144126
git add package.json
145127
git add package-lock.json
146-
git commit -m "release: updated package to ${{ needs.build.outputs.version }} [skip ci]"
128+
git commit -m "release: updated package to ${{ steps.bump.outputs.version }} [skip ci]"
147129
148130
- name: Push changes
149131
run: |
150-
git push origin release/${{ needs.build.outputs.version }}
132+
git push origin release/${{ steps.bump.outputs.version }}
151133
152134
- name: Create Pull Request
153135
uses: peter-evans/create-pull-request@v5
154136
with:
155137
token: ${{ secrets.GITHUB_TOKEN }}
156-
commit-message: "release: updated package to ${{ needs.build.outputs.version }} [skip ci]"
157-
title: "Release ${{ needs.build.outputs.version }}"
138+
commit-message: "release: updated package to ${{ steps.bump.outputs.version }} [skip ci]"
139+
title: "Release ${{ steps.bump.outputs.version }}"
158140
body: |
159-
This PR contains the changes for release ${{ needs.build.outputs.version }}.
141+
This PR contains the changes for release ${{ steps.bump.outputs.version }}.
142+
160143
Changes:
161144
- Updated version in package.json
162145
- Updated changelog
163-
branch: release/${{ needs.build.outputs.version }}
146+
branch: release/${{ steps.bump.outputs.version }}
164147
base: master
165148
labels: |
166149
release
167-
${{ needs.build.outputs.version }}
150+
${{ steps.bump.outputs.version }}
168151
169152
- name: Create a release
170153
id: new_release
@@ -174,22 +157,17 @@ jobs:
174157
script: |
175158
const repo_name = context.payload.repository.full_name
176159
const response = await github.request('POST /repos/' + repo_name + '/releases', {
177-
tag_name: '${{ needs.build.outputs.version }}',
178-
name: '${{ needs.build.outputs.version }}',
160+
tag_name: '${{ steps.bump.outputs.version }}',
161+
name: '${{ steps.bump.outputs.version }}',
179162
body: '${{ steps.release-notes.outputs.notes }}',
180163
prerelease: false,
181164
generate_release_notes: true
182165
})
183166
core.setOutput('upload_url', response.data.upload_url)
184167
185-
- name: Create SHA256 checksum
186-
run: |
187-
sha256sum vsix/fabric8-analytics-${{ needs.build.outputs.version }}.vsix > vsix/fabric8-analytics-${{ needs.build.outputs.version }}.vsix.sha256
188-
189168
- name: Upload packages and checksums as release assets
190-
working-directory: vsix
191169
run: |
192-
for file in *
170+
for file in fabric8-analytics-${{ steps.bump.outputs.version }}.vsix*
193171
do
194172
asset_name=$(basename "$file")
195173
upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g")

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ ca-lsp-server.tar
2020
ca-lsp-server/
2121
.DS_Store
2222
*.tar.*
23-
.history
23+
.history
24+
25+
# VSIX package files
26+
*.vsix
27+
*.vsix.sha256

0 commit comments

Comments
 (0)