Skip to content

Commit cda65e3

Browse files
committed
ci: fix Github release creation
Shift the creation of the release into a new job, since the release needs different permissions than the build/package job needs. Signed-off-by: Jan Kraemer <jan.kraemer@vector.com>
1 parent 51f0250 commit cda65e3

File tree

1 file changed

+24
-42
lines changed

1 file changed

+24
-42
lines changed

.github/workflows/package-silkit.yml

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ on:
77
required: true
88
type: string
99
silkit_source_ref:
10-
description: 'Commit ref of the repo with the SIL Kit packaging sources. Choose carefully'
10+
description: 'Ref of the SIL Kit sources repo.'
1111
required: false
1212
type: string
1313
default: 'main'
1414
silkit_pkg_ref:
15-
description: 'sil-kit-pkg ref used/created for a release'
15+
description: 'sil-kit-pkg ref. Creates a release if not empty'
1616
required: false
1717
type: string
1818
debian_fullname:
@@ -41,6 +41,7 @@ jobs:
4141
image: ghcr.io/vectorgrp/sil-kit-docker-build/sil-kit-ci-packaging-ubuntu-20.04:main
4242
env:
4343
ARTIFACT_NAME: silkit-ubuntu-20.04-deb
44+
4445
steps:
4546

4647
- name: Checkout (sil-kit-pkg)
@@ -111,6 +112,7 @@ jobs:
111112
--distro ubuntu
112113
113114
- name: Artifact
115+
id: artifact
114116
uses: actions/upload-artifact@v4
115117
with:
116118
name: ${{ env.ARTIFACT_NAME }}
@@ -121,40 +123,6 @@ jobs:
121123
./${{ env.PKG_OUTDIR }}/*.*deb
122124
retention-days: 1
123125

124-
- name: Prepare artifact
125-
if: inputs.silkit_pkg_ref != ''
126-
run: |
127-
cd $PKG_OUTDIR
128-
zip -j ${{ env.ARTIFACT_NAME }}.zip ./*.dsc ./*.build* ./*.changes ./*.*deb
129-
sha256sum ./${{ env.ARTIFACT_NAME }}.zip > ./SHA256
130-
131-
- name: Create git tag
132-
if: inputs.silkit_pkg_ref != ''
133-
uses: actions/github-script@v7
134-
with:
135-
script: |
136-
try {
137-
await github.rest.git.createRef({
138-
owner: context.repo.owner,
139-
repo: context.repo.repo,
140-
ref: 'refs/tags/${{ inputs.silkit_pkg_ref }}',
141-
sha: context.sha,
142-
})
143-
} catch(error) {
144-
core.warning("Could not create the specified ref, continuing without it!")
145-
}
146-
147-
- name: Release artifact
148-
if: inputs.silkit_pkg_ref != ''
149-
uses: softprops/action-gh-release@v2
150-
with:
151-
prerelease: ${{ contains(inputs.silkit_pkg_ref, '-rc') }}
152-
draft: false
153-
tag_name: ${{ inputs.silkit_pkg_ref }}
154-
name: ${{ inputs.silkit_pkg_ref }}
155-
files: |
156-
${{ env.PKG_OUTDIR }}/${{ env.ARTIFACT_NAME }}.zip
157-
${{ env.PKG_OUTDIR }}/SHA256
158126

159127
package_almalinux:
160128
runs-on: ubuntu-latest
@@ -164,6 +132,7 @@ jobs:
164132
options: --privileged
165133
env:
166134
ARTIFACT_NAME: silkit-almalinux-9-rpm
135+
167136
steps:
168137

169138
- name: Checkout (sil-kit-pkg)
@@ -229,19 +198,31 @@ jobs:
229198
--distro fedora
230199
231200
- name: Artifact
201+
id: artifact
232202
uses: actions/upload-artifact@v4
233203
with:
234204
name: ${{ env.ARTIFACT_NAME }}
235205
path: |
236206
./${{ env.PKG_OUTDIR }}/*.rpm
237207
retention-days: 1
238208

209+
210+
make-release:
211+
runs-on: ubuntu-latest
212+
needs: [package_ubuntu, package_almalinux]
213+
permissions:
214+
contents: write
215+
216+
steps:
217+
218+
- name: download_artifact
219+
uses: actions/download-artifact@v4
220+
239221
- name: Prepare artifact
240222
if: inputs.silkit_pkg_ref != ''
241223
run: |
242-
cd $PKG_OUTDIR
243-
zip -j ${{ env.ARTIFACT_NAME }}-el9.zip ./*.rpm
244-
sha256sum ./${{ env.ARTIFACT_NAME }}-el9.zip > ./SHA256
224+
sha256sum silkit-almalinux-9-rpm/* >> ./SHA256
225+
sha256sum silkit-ubuntu-20.04-deb/* >> ./SHA256
245226
246227
- name: Create git tag
247228
if: inputs.silkit_pkg_ref != ''
@@ -259,6 +240,7 @@ jobs:
259240
core.warning("Could not create the specified ref, continuing without it!")
260241
}
261242
243+
262244
- name: Release artifact
263245
if: inputs.silkit_pkg_ref != ''
264246
uses: softprops/action-gh-release@v2
@@ -268,6 +250,6 @@ jobs:
268250
tag_name: ${{ inputs.silkit_pkg_ref }}
269251
name: ${{ inputs.silkit_pkg_ref }}
270252
files: |
271-
${{ env.PKG_OUTDIR }}/${{ env.ARTIFACT_NAME }}.zip
272-
${{ env.PKG_OUTDIR }}/SHA256
273-
253+
${{ github.workspace }}/silkit-ubuntu-20.04-deb/*
254+
${{ github.workspace }}/silkit-almalinux-9-rpm/*
255+
${{ github.workspace }}/SHA256

0 commit comments

Comments
 (0)