-
Notifications
You must be signed in to change notification settings - Fork 7
140 lines (128 loc) · 4.97 KB
/
github-release.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
132
133
134
135
136
137
138
139
140
name: GitHub Release
on:
workflow_dispatch:
inputs:
version:
description: 'release version'
required: true
default: '2023.3.0'
llvm_run_id:
description: 'llvm workflow run id'
default: "latest"
required: true
halide_run_id:
description: 'halide workflow run id'
default: "latest"
required: true
rust_run_id:
description: 'rust workflow run id'
default: "latest"
required: true
cctools_run_id:
description: 'cctools workflow run id'
default: "latest"
required: true
dry-run:
description: 'dry run (skip release)'
required: true
type: boolean
default: 'true'
draft-release:
description: 'Create draft release'
required: true
type: boolean
default: 'false'
jobs:
publish:
name: Publish packages
runs-on: ubuntu-20.04
steps:
- name: Download llvm
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$Workflow = "LLVM prebuilt"
$Repository = $Env:GITHUB_REPOSITORY
$RunId = '${{ github.event.inputs.llvm_run_id }}'
if ($RunId -eq 'latest') {
$RunId = $(gh run list -R $Repository -w $Workflow --json 'status,databaseId,conclusion') |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
Select-Object -First 1 -ExpandProperty databaseId
}
Write-Host "Downloading run $RunId ($Workflow)"
& gh run download -R $Repository $RunId
- name: Download halide
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$Workflow = "halide prebuilt"
$Repository = $Env:GITHUB_REPOSITORY
$RunId = '${{ github.event.inputs.halide_run_id }}'
if ($RunId -eq 'latest') {
$RunId = $(gh run list -R $Repository -w $Workflow --json 'status,databaseId,conclusion') |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
Select-Object -First 1 -ExpandProperty databaseId
}
Write-Host "Downloading run $RunId ($Workflow)"
& gh run download -R $Repository $RunId
- name: Download rust
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$Workflow = "Rust prebuilt"
$Repository = $Env:GITHUB_REPOSITORY
$RunId = '${{ github.event.inputs.rust_run_id }}'
if ($RunId -eq 'latest') {
$RunId = $(gh run list -R $Repository -w $Workflow --json 'status,databaseId,conclusion') |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
Select-Object -First 1 -ExpandProperty databaseId
}
Write-Host "Downloading run $RunId ($Workflow)"
& gh run download -R $Repository $RunId
- name: Download cctools
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$Workflow = "cctools prebuilt"
$Repository = $Env:GITHUB_REPOSITORY
$RunId = '${{ github.event.inputs.cctools_run_id }}'
if ($RunId -eq 'latest') {
$RunId = $(gh run list -R $Repository -w $Workflow --json 'status,databaseId,conclusion') |
ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } |
Select-Object -First 1 -ExpandProperty databaseId
}
Write-Host "Downloading run $RunId ($Workflow)"
& gh run download -R $Repository $RunId
- name: Create GitHub Release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
if: ${{ github.event.inputs.dry-run == 'false' }}
run: |
$RootDir = Get-Location
Get-ChildItem *.tar.xz -Depth 2 | % { Move-Item $_.FullName $RootDir -Force }
Get-ChildItem . -Directory -Recurse | % { if (-Not (Test-Path ($_.FullName + "\*"))) { Remove-Item $_ } }
$HashPath = 'checksums'
$Version = '${{ github.event.inputs.version }}'
$DraftRelease = [System.Convert]::ToBoolean('${{ github.event.inputs.draft-release }}')
$Files = Get-Item * | % { Get-FileHash -Algorithm SHA256 $_.FullName }
$Files | % { "$($_.Hash) $(Split-Path $_.Path -Leaf)" } | Out-File -FilePath $HashPath -Append -Encoding ASCII
echo "::group::checksums"
Get-Content $HashPath
echo "::endgroup::"
$ReleaseTag = "v${Version}"
$Repository = $Env:GITHUB_REPOSITORY
$ReleaseTitle = "v${Version}"
$Params = @(
$ReleaseTag,
'--repo', $Repository,
'--title', $ReleaseTitle
)
if ($DraftRelease) {
$Params += @('--draft')
}
& gh release create $Params ./*