forked from unraid/ci-runner-farm
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (105 loc) · 4.69 KB
/
Copy pathrelease-please.yml
File metadata and controls
115 lines (105 loc) · 4.69 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
name: Release Please
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
release-please:
# Forks keep this workflow for upstream parity, but must never create a
# release PR, tag, release, or asset from their own main branch.
if: ${{ github.repository == 'unraid/ci-runner-farm' }}
runs-on: ubuntu-latest
outputs:
pr: ${{ steps.release.outputs.pr || '' }}
release_created: ${{ steps.release.outputs.release_created || 'false' }}
tag_name: ${{ steps.release.outputs.tag_name || '' }}
steps:
- id: release
name: Release Please
uses: googleapis/release-please-action@0dfd8538845b8e92600d271a895a5372865d4062
with:
token: ${{ secrets.UNRAID_BOT_GITHUB_ADMIN_TOKEN || github.token }}
# On the open release PR, regenerate the self-contained .plg so its version
# entities and embedded payload match the version release-please just bumped,
# then commit it back onto the PR branch.
prepare-plugin-release-pr:
needs: release-please
if: ${{ github.repository == 'unraid/ci-runner-farm' && needs.release-please.outputs.pr != '' }}
runs-on: ubuntu-latest
steps:
- name: Checkout release PR
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
ref: ${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}
token: ${{ secrets.UNRAID_BOT_GITHUB_ADMIN_TOKEN || github.token }}
fetch-depth: 0
- name: Prepare plugin release metadata
shell: bash
env:
BUILD_NUMBER: ${{ github.run_number }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
version="$(python3 -c 'import json;print(json.load(open(".release-please-manifest.json"))["."])')"
printf '%s\n' "$version" > VERSION
chmod +x build-plg.sh
INTERNAL_VERSION="$version" ./build-plg.sh
- name: Commit plugin release metadata
shell: bash
run: |
set -euo pipefail
if [[ -z "$(git status --porcelain)" ]]; then
echo "Plugin release metadata is already current"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add VERSION ci-runner-farm.plg
git commit -m "chore(release): prepare plugin metadata"
git push origin HEAD:${{ fromJSON(needs.release-please.outputs.pr).headBranchName }}
validate-plugin-release:
needs: release-please
if: ${{ github.repository == 'unraid/ci-runner-farm' && needs.release-please.outputs.release_created == 'true' }}
uses: ./.github/workflows/release.yml
with:
tag: ${{ needs.release-please.outputs.tag_name }}
# When the release PR merges and release-please cuts the tag + GitHub Release,
# attach the tagged .plg as the release asset that CA / Unraid installs from.
publish-plugin-release:
needs:
- release-please
- validate-plugin-release
if: ${{ github.repository == 'unraid/ci-runner-farm' && needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout release tag
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
ref: ${{ needs.release-please.outputs.tag_name }}
- name: Upload plugin release artifact
env:
GH_TOKEN: ${{ secrets.UNRAID_BOT_GITHUB_ADMIN_TOKEN || github.token }}
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }}
shell: bash
run: |
set -euo pipefail
# Rebuild the package reproducibly from the tagged src; its MD5 matches
# the packageMD5 the committed .plg already advertises. Upload it under
# the version-pinned asset name the .plg's packageName entity expects.
chmod +x build-plg.sh
./build-plg.sh --tgz-only
asset="$(sed -n 's/^<!ENTITY packageName[[:space:]]*"\([^"]*\)">$/\1/p' ci-runner-farm.plg)"
[[ -n "$asset" ]] || { echo "::error::packageName entity missing in .plg" >&2; exit 1; }
plg_md5="$(sed -n 's/^<!ENTITY packageMD5[[:space:]]*"\([0-9a-f]*\)">$/\1/p' ci-runner-farm.plg)"
tgz_md5="$(md5sum ci-runner-farm.tgz | cut -d' ' -f1)"
[[ "$plg_md5" == "$tgz_md5" ]] || { echo "::error::rebuilt package md5 ($tgz_md5) != committed .plg packageMD5 ($plg_md5)" >&2; exit 1; }
cp ci-runner-farm.tgz "$asset"
gh release upload "$RELEASE_TAG" ci-runner-farm.plg "$asset" --clobber