forked from nim-works/nimskull
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (117 loc) · 3.88 KB
/
publisher.yml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Publish built artifacts
on:
push:
branches:
- devel
workflow_call:
inputs:
run_id:
required: false
type: string
description: The run ID with artifacts to be published
default: ${{ github.run_id }}
# Run every script actions in bash
defaults:
run:
shell: bash
# Since we will be pushing, make sure that only one instance can run at a time.
concurrency: publisher
jobs:
publisher:
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
environment:
name: release
url: ${{ steps.release.outputs.url }}
steps:
- name: Obtain latest successful run id
id: finder
run: |
run_id=
if [[ -n $INPUT_RUNID ]]; then
echo "Using input run id"
run_id=$INPUT_RUNID
else
echo "Querying latest run id for $COMMIT"
run_id=$(gh run list \
-c "$COMMIT" \
-w "$WORKFLOW" \
-s "$CONCLUSION" \
--limit 1 \
--json databaseId \
--jq '.[].databaseId')
fi
if [[ -z $run_id ]]; then
echo "::error::Could not find any CI run for commit $COMMIT"
exit 1
fi
echo "run_id=$run_id" >> "$GITHUB_OUTPUT"
env:
COMMIT: ${{ github.event.after }}
WORKFLOW: ci.yml
CONCLUSION: success
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
INPUT_RUNID: ${{ inputs.run_id }}
# Download the latest instance of artifacts from a build done previously
- name: Download generated source archive
uses: actions/download-artifact@v4
with:
run-id: ${{ steps.finder.outputs.run_id }}
# Keep up-to-date with ci.yml
name: source archive
path: release-staging
github-token: ${{ github.token }}
- name: Download generated release binaries
uses: actions/download-artifact@v4
with:
run-id: ${{ steps.finder.outputs.run_id }}
# Keep up-to-date with ci.yml
pattern: release binaries *
merge-multiple: "true"
path: release-staging
github-token: ${{ github.token }}
- name: Download release manifest tool
uses: actions/download-artifact@v4
with:
run-id: ${{ steps.finder.outputs.run_id }}
# Keep up-to-date with ci.yml
name: release manifest tool
path: release-staging
github-token: ${{ github.token }}
- id: release-files
name: Create release manifest
run: |
# Github Artifacts strip executable permissions so it has to be set again
chmod 755 release_manifest
# Create a new release manifest
./release_manifest add *.json
toUpload=$(./release_manifest files-to-upload)
delimiter=EOF-$(uuidgen)
cat <<EOF >> $GITHUB_OUTPUT
result<<$delimiter
$toUpload
$delimiter
EOF
version=$(./release_manifest version)
prerelease=true
[[ $version == *-* ]] || prerelease=false
echo "version=$version" >> $GITHUB_OUTPUT
echo "prerelease=$prerelease" >> $GITHUB_OUTPUT
working-directory: release-staging
- id: release-desc
name: Create release description
run: |
- id: release
name: Create pre-release
uses: softprops/[email protected]
with:
prerelease: ${{ steps.release-files.outputs.prerelease }}
files: ${{ steps.release-files.outputs.result }}
tag_name: ${{ steps.release-files.outputs.version }}
fail_on_unmatched_files: true
target_commitish: ${{ github.event.after }}
body: |
Continuous delivery for commit ${{ github.event.after }}