Skip to content

Commit e9b9b5d

Browse files
mamoreau-devolutionsawakecoding
authored andcommitted
add release workflow
1 parent 1a54bd2 commit e9b9b5d

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: GitHub Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'release version'
7+
required: true
8+
default: '2023.1.0'
9+
llvm_run_id:
10+
description: 'llvm workflow run id'
11+
default: "latest"
12+
required: true
13+
halide_run_id:
14+
description: 'halide workflow run id'
15+
default: "latest"
16+
required: true
17+
rust_run_id:
18+
description: 'rust workflow run id'
19+
default: "latest"
20+
required: true
21+
cctools_run_id:
22+
description: 'cctools workflow run id'
23+
default: "latest"
24+
required: true
25+
darling_run_id:
26+
description: 'darling workflow run id'
27+
default: "latest"
28+
required: true
29+
dry-run:
30+
description: 'dry run (skip release)'
31+
required: true
32+
type: boolean
33+
default: 'true'
34+
draft-release:
35+
description: 'Create draft release'
36+
required: true
37+
type: boolean
38+
default: 'false'
39+
40+
jobs:
41+
publish:
42+
name: Publish packages
43+
runs-on: ubuntu-20.04
44+
45+
steps:
46+
- name: Download llvm
47+
shell: pwsh
48+
env:
49+
GH_TOKEN: ${{ github.token }}
50+
run: |
51+
$WorkflowName = "LLVM prebuilt"
52+
$RunId = '${{ github.event.inputs.llvm_run_id }}'
53+
if ($RunId -eq 'latest') {
54+
$RunId = $(gh run list -w $WorkflowName --json 'status,databaseId,conclusion') |
55+
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
56+
Select-Object -First 1 -ExpandProperty databaseId
57+
}
58+
Write-Host "Downloading run $RunId ($WorkflowName)"
59+
& gh run download $RunId
60+
61+
- name: Download halide
62+
shell: pwsh
63+
env:
64+
GH_TOKEN: ${{ github.token }}
65+
run: |
66+
$WorkflowName = "halide prebuilt"
67+
$RunId = '${{ github.event.inputs.halide_run_id }}'
68+
if ($RunId -eq 'latest') {
69+
$RunId = $(gh run list -w $WorkflowName --json 'status,databaseId,conclusion') |
70+
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
71+
Select-Object -First 1 -ExpandProperty databaseId
72+
}
73+
Write-Host "Downloading run $RunId ($WorkflowName)"
74+
& gh run download $RunId
75+
76+
- name: Download rust
77+
shell: pwsh
78+
env:
79+
GH_TOKEN: ${{ github.token }}
80+
run: |
81+
$WorkflowName = "Rust prebuilt"
82+
$RunId = '${{ github.event.inputs.rust_run_id }}'
83+
if ($RunId -eq 'latest') {
84+
$RunId = $(gh run list -w $WorkflowName --json 'status,databaseId,conclusion') |
85+
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
86+
Select-Object -First 1 -ExpandProperty databaseId
87+
}
88+
Write-Host "Downloading run $RunId ($WorkflowName)"
89+
& gh run download $RunId
90+
91+
- name: Download cctools
92+
shell: pwsh
93+
env:
94+
GH_TOKEN: ${{ github.token }}
95+
run: |
96+
$WorkflowName = "cctools prebuilt"
97+
$RunId = '${{ github.event.inputs.cctools_run_id }}'
98+
if ($RunId -eq 'latest') {
99+
$RunId = $(gh run list -w $WorkflowName --json 'status,databaseId,conclusion') |
100+
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
101+
Select-Object -First 1 -ExpandProperty databaseId
102+
}
103+
Write-Host "Downloading run $RunId ($WorkflowName)"
104+
& gh run download $RunId
105+
106+
- name: Download darling
107+
shell: pwsh
108+
env:
109+
GH_TOKEN: ${{ github.token }}
110+
run: |
111+
$WorkflowName = "darling prebuilt"
112+
$RunId = '${{ github.event.inputs.darling_run_id }}'
113+
if ($RunId -eq 'latest') {
114+
$RunId = $(gh run list -w $WorkflowName --json 'status,databaseId,conclusion') |
115+
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
116+
Select-Object -First 1 -ExpandProperty databaseId
117+
}
118+
Write-Host "Downloading run $RunId ($WorkflowName)"
119+
& gh run download $RunId
120+
121+
- name: Create GitHub Release
122+
shell: pwsh
123+
env:
124+
GH_TOKEN: ${{ github.token }}
125+
if: ${{ github.event.inputs.dry-run == 'false' }}
126+
run: |
127+
$HashPath = 'checksums'
128+
$Version = '${{ github.event.inputs.version }}'
129+
$DraftRelease = [System.Convert]::ToBoolean('${{ github.event.inputs.draft-release }}')
130+
$Files = Get-Item * | % { Get-FileHash -Algorithm SHA256 $_.FullName }
131+
$Files | % { "$($_.Hash) $(Split-Path $_.Path -Leaf)" } | Out-File -FilePath $HashPath -Append -Encoding ASCII
132+
133+
echo "::group::checksums"
134+
Get-Content $HashPath
135+
echo "::endgroup::"
136+
137+
$ReleaseTag = "v$Version"
138+
$Repository = $Env:GITHUB_REPOSITORY
139+
$ReleaseTitle = "v${Version}"
140+
141+
$Params = @(
142+
$ReleaseTag,
143+
'--repo', $Repository,
144+
'--title', $ReleaseTitle
145+
)
146+
147+
if ($DraftRelease) {
148+
$Params += @('--draft')
149+
}
150+
151+
& gh release create $Params ./*

0 commit comments

Comments
 (0)