Skip to content

Commit 896643d

Browse files
authored
Add/update GHA assets (#465)
The patch enforces a standardized asset baseline using simp/puppetsync, and may also apply other updates to ensure conformity.
1 parent 5a2fa10 commit 896643d

6 files changed

+65
-41
lines changed

.github/workflows/pr_glci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
outputs:
6868
valid: ${{ steps.validate-glci-file.outputs.valid }}
6969
steps:
70-
- uses: actions/checkout@v2
70+
- uses: actions/checkout@v3
7171
with:
7272
repository: ${{ github.event.pull_request.head.repo.full_name }}
7373
ref: ${{ github.event.pull_request.head.ref }}
@@ -80,11 +80,11 @@ jobs:
8080

8181
contributor-permissions:
8282
name: 'PR contributor check'
83-
runs-on: ubuntu-18.04
83+
runs-on: ubuntu-latest
8484
outputs:
8585
permitted: ${{ steps.user-repo-permissions.outputs.permitted }}
8686
steps:
87-
- uses: actions/github-script@v3
87+
- uses: actions/github-script@v6
8888
id: user-repo-permissions
8989
with:
9090
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -135,7 +135,7 @@ jobs:
135135
# - Not implemented: For some reason, this conditional always fails
136136
# - Unnecessary if on>pull_request_target>types doesn't include 'closed'
137137
if: github.event_name == 'pull_request_target' && ( github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' ) && github.event.pull_request.merged != 'true' && needs.glci-syntax.outputs.valid == 'true' && needs.contributor-permissions.outputs.permitted == 'true'
138-
runs-on: ubuntu-18.04
138+
runs-on: ubuntu-latest
139139
steps:
140140
# Things we'd like to do:
141141
# - [ ] if there's no GitLab mirror, make one
@@ -145,7 +145,7 @@ jobs:
145145
# - "created|waiting_for_resource|preparing|pending|running"
146146
# - Exception: don't cancel existing pipeline for our own commit
147147
# - [x] if PR: force-push branch to GitLab
148-
- uses: actions/checkout@v2
148+
- uses: actions/checkout@v3
149149
if: needs.contributor-permissions.outputs.permitted == 'true'
150150
with:
151151
clean: true

.github/workflows/pr_glci_cleanup.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
# `on` section is inadventently modified without considering the security
4141
# implications.
4242
if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
43-
runs-on: ubuntu-18.04
43+
runs-on: ubuntu-latest
4444
steps:
45-
- uses: actions/checkout@v2
45+
- uses: actions/checkout@v3
4646
with:
4747
repository: ${{ github.event.pull_request.head.repo.full_name }}
4848
ref: ${{ github.event.pull_request.head.ref }}

.github/workflows/pr_glci_manual.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ------------------------------------------------------------------------------
33
#
44
# NOTICE: **This file is maintained with puppetsync**
5-
#
5+
66
# This file is updated automatically as part of a standardized asset baseline.
77
#
88
# The next baseline sync will overwrite any local changes to this file!
@@ -42,15 +42,15 @@ on:
4242
jobs:
4343
glci-syntax:
4444
name: '.gitlab-ci.yml Syntax'
45-
runs-on: ubuntu-18.04
45+
runs-on: ubuntu-latest
4646
outputs:
4747
valid: ${{ steps.validate-glci-file.outputs.valid }}
4848
pr_head_ref: ${{ steps.get-pr.outputs.pr_head_ref }}
4949
pr_head_sha: ${{ steps.get-pr.outputs.pr_head_sha }}
5050
pr_head_label: ${{ steps.get-pr.outputs.pr_head_label }}
5151
pr_head_full_name: ${{ steps.get-pr.outputs.pr_full_name }}
5252
steps:
53-
- uses: actions/github-script@v3
53+
- uses: actions/github-script@v6
5454
id: get-pr
5555
with:
5656
github-token: ${{secrets.NO_SCOPE_GITHUB_TOKEN}}
@@ -90,7 +90,7 @@ jobs:
9090
core.setOutput( 'pr_head_ref', pr.data.head.ref )
9191
core.setOutput( 'pr_head_label', pr.data.head.label )
9292
core.setOutput( 'pr_head_full_name', pr.data.head.full_name )
93-
- uses: actions/checkout@v2
93+
- uses: actions/checkout@v3
9494
with:
9595
repository: ${{ steps.get-pr.outputs.pr_head_full_name }}
9696
ref: ${{ steps.get-pr.outputs.pr_head_sha }}
@@ -106,9 +106,9 @@ jobs:
106106
trigger-when-user-has-repo-permissions:
107107
name: 'Trigger CI'
108108
needs: [ glci-syntax ]
109-
runs-on: ubuntu-18.04
109+
runs-on: ubuntu-latest
110110
steps:
111-
- uses: actions/checkout@v2
111+
- uses: actions/checkout@v3
112112
with:
113113
repository: ${{ needs.glci-syntax.outputs.pr_head_full_name }}
114114
ref: ${{ needs.glci-syntax.outputs.pr_head_sha }}
@@ -129,7 +129,7 @@ jobs:
129129
### needs: [ glci-syntax ]
130130
### name: 'Examine Context contents'
131131
### if: always()
132-
### runs-on: ubuntu-18.04
132+
### runs-on: ubuntu-latest
133133
### steps:
134134
### - name: Dump contexts
135135
### env:

.github/workflows/release_rpms.yml

+37-16
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ on:
7171
description: "Dry run (Test-build RPMs)"
7272
required: false
7373
default: 'no'
74-
verbose:
75-
description: 'Verbose RPM builds when "yes"'
74+
#verbose:
75+
# description: 'Verbose RPM builds when "yes"'
76+
# required: false
77+
# default: 'no'
78+
rebuild_number:
79+
description: 'If this is an RPM rebuild, put the number of the rebuild here'
7680
required: false
77-
default: 'no'
81+
default: ''
82+
7883

7984
env:
8085
TARGET_REPO: ${{ (github.event.inputs.target_repo != null && format('{0}/{1}', github.repository_owner, github.event.inputs.target_repo)) || github.repository }}
@@ -99,13 +104,13 @@ jobs:
99104
100105
if [[ "$RELEASE_TAG" =~ ^(simp-|v)?([0-9]+\.[0-9]+\.[0-9]+)(-(rc|RC|[Aa]lpha|[Bb]eta|pre|post)?([0-9]+)?)?$ ]]; then
101106
if [ -n "${BASH_REMATCH[5]}" ]; then
102-
echo "::set-output name=prebuild_number::${BASH_REMATCH[5]#-}"
107+
echo "{prebuild_number}={${BASH_REMATCH[5]#-}}" >> $GITHUB_OUTPUT
103108
fi
104109
if [ -n "${BASH_REMATCH[3]}" ]; then
105-
echo "::set-output name=prebuild_suffix::${BASH_REMATCH[3]#-}"
110+
echo "{prebuild_suffix}={${BASH_REMATCH[3]#-}}" >> $GITHUB_OUTPUT
106111
fi
107112
if [ -n "${BASH_REMATCH[2]}" ]; then
108-
echo "::set-output name=build_semver::${BASH_REMATCH[2]}"
113+
echo "{build_semver}={${BASH_REMATCH[2]}}" >> $GITHUB_OUTPUT
109114
fi
110115
else
111116
printf '::error ::Release Tag format is not SemVer, X.Y.Z-R, X.Y.Z-<prerelease>: "%s"\n' "$RELEASE_TAG"
@@ -121,7 +126,7 @@ jobs:
121126
env:
122127
AUTOCREATE_RELEASE: ${{ github.event.inputs.autocreate_release }}
123128
PREBUILD_TAG: ${{ steps.validate-inputs.outputs.prebuild_suffix }}
124-
uses: actions/github-script@v4
129+
uses: actions/github-script@v6
125130
with:
126131
github-token: ${{ github.event.inputs.target_repo_token || secrets.GITHUB_TOKEN }}
127132
script: |
@@ -189,7 +194,7 @@ jobs:
189194
)
190195
191196
- name: Checkout code
192-
uses: actions/checkout@v2
197+
uses: actions/checkout@v3
193198
with:
194199
repository: ${{ env.TARGET_REPO }}
195200
ref: ${{ env.RELEASE_TAG }}
@@ -221,6 +226,22 @@ jobs:
221226
printf '::warning ::Added file build/rpm_metadata/release with content "%s"\n' "$(cat build/rpm_metadata/release)"
222227
fi
223228
229+
- name: 'Customize RPM Release tag via build/rpm_metadata/release (RPM rebuild)'
230+
if: ${{ github.event.inputs.rebuild_number != '' }}
231+
env:
232+
BUILD_SEMVER: ${{ steps.validate-inputs.outputs.build_semver }}
233+
REBUILD_NUMBER: ${{ github.event.inputs.rebuild_number }}
234+
run: |
235+
mkdir -p build/rpm_metadata
236+
# simp-doc uses a unique data format in /release
237+
if [[ "$TARGET_REPO" =~ ^simp\/simp-doc$ ]]; then
238+
echo "version: $BUILD_SEMVER" > build/rpm_metadata/release
239+
echo "release: $REBUILD_NUMBER" > build/rpm_metadata/release
240+
else
241+
echo "$REBUILD_NUMBER" > build/rpm_metadata/release
242+
fi
243+
printf '::warning ::Added file build/rpm_metadata/release with content "%s"\n' "$(cat build/rpm_metadata/release)"
244+
224245
- name: >
225246
Build & Sign RPMs for
226247
${{ github.event.inputs.release_tag }}
@@ -234,30 +255,30 @@ jobs:
234255
simp_core_ref_for_building_rpms: ${{ secrets.SIMP_CORE_REF_FOR_BUILDING_RPMS }}
235256
simp_builder_docker_image: 'docker.io/simpproject/simp_build_${{ github.event.inputs.build_container_os }}:latest'
236257
path_to_build: "${{ (github.event.inputs.path_to_build != null && format('{0}/{1}', github.workspace, github.event.inputs.path_to_build)) || github.workspace }}"
237-
verbose: ${{ github.event.inputs.verbose }}
258+
verbose: 'no' #${{ github.event.inputs.verbose }}
238259
239260
- name: "Wipe all previous assets from GitHub Release (when clean == 'yes')"
240261
if: ${{ github.event.inputs.clean == 'yes' && github.event.inputs.dry_run != 'yes' }}
241-
uses: actions/github-script@v4
262+
uses: actions/github-script@v6
242263
env:
243264
release_id: ${{ steps.release-api.outputs.id }}
244265
with:
245266
github-token: ${{ github.event.inputs.target_repo_token || secrets.GITHUB_TOKEN }}
246267
script: |
247268
const release_id = process.env.release_id
248269
const [owner, repo] = process.env.TARGET_REPO.split('/')
249-
const existingAssets = await github.repos.listReleaseAssets({ owner, repo, release_id })
270+
const existingAssets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id })
250271
251272
console.log( ` !! !! Wiping ALL uploaded assets for ${owner}/${repo} release (id: ${release_id})`)
252273
existingAssets.data.forEach(async function(asset){
253274
asset_id = asset.id
254275
console.log( ` !! !! !! Wiping existing asset for ${asset.name} (id: ${asset_id})`)
255-
await github.repos.deleteReleaseAsset({ owner, repo, asset_id })
276+
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id })
256277
})
257278
258279
- name: "Upload RPM file(s) to GitHub Release (dry_run != 'yes')"
259280
if: ${{ github.event.inputs.dry_run != 'yes' }}
260-
uses: actions/github-script@v4
281+
uses: actions/github-script@v6
261282
env:
262283
rpm_file_paths: ${{ steps.build-and-sign-rpm.outputs.rpm_file_paths }}
263284
rpm_gpg_file: ${{ steps.build-and-sign-rpm.outputs.rpm_gpg_file }}
@@ -274,12 +295,12 @@ jobs:
274295
async function clobberAsset (name, owner, repo, release_id ){
275296
console.log( ` -- clobber asset ${name}: owner: ${owner} repo: ${repo} release_id: ${release_id}` )
276297
277-
const existingAssets = await github.repos.listReleaseAssets({ owner, repo, release_id })
298+
const existingAssets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id })
278299
const matchingAssets = existingAssets.data.filter(item => item.name == name);
279300
if ( matchingAssets.length > 0 ){
280301
asset_id = matchingAssets[0].id
281302
console.log( ` !! !! Clobbering existing asset for ${name} (id: ${asset_id})`)
282-
await github.repos.deleteReleaseAsset({ owner, repo, asset_id })
303+
await github.rest.repos.deleteReleaseAsset({ owner, repo, asset_id })
283304
return(true)
284305
}
285306
return(false)
@@ -297,7 +318,7 @@ jobs:
297318
};
298319
299320
console.log( ` == Uploading asset ${name}: ${assetContentType}` )
300-
const uploadAssetResponse = await github.repos.uploadReleaseAsset({
321+
const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({
301322
owner, repo, release_id, data, name, headers,
302323
})
303324
return( uploadAssetResponse );

.github/workflows/tag_deploy_github-rpms.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
prerelease: ${{ steps.tag-check.outputs.prerelease }}
5050
steps:
5151
- name: Checkout code
52-
uses: actions/checkout@v2
52+
uses: actions/checkout@v3
5353
with:
5454
ref: ${{ github.ref }}
5555
clean: true
@@ -62,7 +62,6 @@ jobs:
6262
annotation="$(git for-each-ref "$GITHUB_REF" --format='%(contents)' --count=1)"
6363
annotation_title="$(echo "$annotation" | head -1)"
6464
65-
6665
if [[ "$tag" =~ ^(simp-|v)?[0-9]+\.[0-9]+\.[0-9]+(-(rc|alpha|beta|pre|post)?([0-9]+)?)?$ ]]; then
6766
if [ -n "${BASH_REMATCH[2]}" ]; then
6867
prerelease=yes
@@ -73,14 +72,15 @@ jobs:
7372
exit 88
7473
fi
7574
76-
echo "::set-output name=tag::${tag}"
77-
echo "::set-output name=prerelease::${prerelease}"
78-
echo "::set-output name=annotation_title::${annotation_title}"
75+
echo "tag=$tag" | tee -a "$GITHUB_OUTPUT"
76+
echo "prerelease=$prerelease" | tee -a "$GITHUB_OUTPUT"
77+
echo "annotation_title=$annotation_title" | tee -a "$GITHUB_OUTPUT"
78+
echo "TARGET_TAG=$tag" | tee -a "$GITHUB_ENV"
7979
8080
# Prepare annotation body as a file for the next step
8181
#
82-
# * The GitHub Release render the text in this file as markdown
83-
# * The file is needed because :set-output only supports single lines
82+
# * The GitHub Release renders the text in this file as markdown
83+
# * The file is needed because GITHUB_OUTPUT only supports single lines
8484
# * The `perl -pe` removes RPM-style date headers from the CHANGELOG,
8585
# because they don't render well as markdown on the Release page
8686
#
@@ -114,15 +114,18 @@ jobs:
114114
steps:
115115
- name: Get tag & annotation info (${{github.ref}})
116116
id: tag-check
117-
run: echo "::set-output name=tag::${GITHUB_REF/refs\/tags\//}"
117+
run: |
118+
tag="${GITHUB_REF/refs\/tags\//}"
119+
echo "tag=$tag" >> $GITHUB_OUTPUT
118120
- name: Trigger RPM release workflow (${{ matrix.os }})
119-
uses: actions/github-script@v4
121+
uses: actions/github-script@v6
120122
env:
121123
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
122124
TARGET_TAG: ${{ steps.tag-check.outputs.tag }}
123125
with:
124126
github-token: ${{ secrets.SIMP_AUTO_GITHUB_TOKEN__REPO_SCOPE }}
125127
script: |
128+
console.log( `== Building tag: '${ process.env.TARGET_TAG }' for os '${{ matrix.os}}'` )
126129
const [owner, repo] = process.env.TARGET_REPO.split('/')
127130
await github.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
128131
owner: owner,

.github/workflows/validate_tokens_asset.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
jobs:
2929
gitlab:
3030
name: 'GitLab token has scope for developer'
31-
runs-on: ubuntu-18.04
31+
runs-on: ubuntu-latest
3232
env:
3333
GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
3434
GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }}
@@ -43,7 +43,7 @@ jobs:
4343
4444
github-no-scope:
4545
name: 'No-scope GitHub token has NO scopes'
46-
runs-on: ubuntu-18.04
46+
runs-on: ubuntu-latest
4747
env:
4848
GITHUB_ORG: ${{ github.event.organization.login }}
4949
NO_SCOPE_GITHUB_TOKEN: ${{secrets.NO_SCOPE_GITHUB_TOKEN}}

0 commit comments

Comments
 (0)