-
-
Notifications
You must be signed in to change notification settings - Fork 465
177 lines (163 loc) · 6.47 KB
/
Copy pathrelease.yml
File metadata and controls
177 lines (163 loc) · 6.47 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: pyRevit Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
notify_only:
description: Run notify job only (skip release pipeline)
type: boolean
default: false
release_url:
description: Published release URL (required for notify-only runs)
type: string
required: false
tag_ref:
description: Release tag to notify for (e.g. v6.5.0.26173+1406)
type: string
required: false
concurrency:
group: pyrevit-release-${{ github.ref }}
cancel-in-progress: true
jobs:
release:
if: github.repository == 'pyrevitlabs/pyRevit' && github.ref_type == 'tag' && github.event_name == 'push'
runs-on: windows-2025
permissions:
contents: write
actions: write
environment: production
outputs:
release_url: ${{ steps.capture_url.outputs.release_url }}
steps:
- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Wait for CI to complete on tagged commit
id: wait_ci
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
for i in $(seq 1 30); do
RUN_ID=$(gh run list \
--workflow ci.yml \
--commit "$GITHUB_SHA" \
--limit 1 \
--json databaseId \
--jq '.[0].databaseId' \
-R "$GITHUB_REPOSITORY")
if [ -n "${RUN_ID:-}" ] && [ "$RUN_ID" != "null" ]; then
echo "Found CI run: $RUN_ID"
gh run watch "$RUN_ID" --exit-status -R "$GITHUB_REPOSITORY"
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "CI run for $GITHUB_SHA not yet started; retry in 20s ($i/30)"
sleep 20
done
echo "Timed out waiting for CI run on $GITHUB_SHA" >&2
exit 1
- name: Download unsigned bin artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: unsigned-bin-${{ github.sha }}
run-id: ${{ steps.wait_ci.outputs.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: bin/
- name: Download stamped release metadata
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: stamped-release-metadata-${{ github.sha }}
run-id: ${{ steps.wait_ci.outputs.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: .
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/Directory.Build.props', 'build/Build.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Run release pipeline
id: pipeline
working-directory: build
env:
DOTNET_ENVIRONMENT: Production
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Build__Channel: release
Signing__TenantId: ${{ secrets.AZURE_TENANT_ID }}
Signing__ClientId: ${{ secrets.AZURE_CLIENT_ID }}
Signing__ClientSecret: ${{ secrets.AZURE_CLIENT_SECRET }}
Signing__Endpoint: ${{ secrets.AZURE_ENDPOINT }}
Signing__SigningAccountName: ${{ secrets.AZURE_CODE_SIGNING_NAME }}
Signing__CertificateProfileName: ${{ secrets.AZURE_CERT_PROFILE_NAME }}
Publish__ChocoToken: ${{ secrets.CHOCO_TOKEN }}
Publish__WingetToken: ${{ secrets.WINGET_GITHUB_TOKEN }}
run: dotnet run -c Release -- release pack sign publish
- name: Capture release URL
id: capture_url
shell: bash
run: |
set -euo pipefail
URL=$(tr -d '\r\n' < dist/github-release-url.txt)
echo "release_url=$URL" >> "$GITHUB_OUTPUT"
- name: Delete temporary CI artifacts
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$ErrorActionPreference = 'Stop'
$headers = @{
Authorization = "Bearer $env:GITHUB_TOKEN"
Accept = "application/vnd.github+json"
"X-GitHub-Api-Version" = "2022-11-28"
}
$artifactNames = @(
"unsigned-bin-${{ github.sha }}",
"stamped-release-metadata-${{ github.sha }}"
)
$listUrl = "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ steps.wait_ci.outputs.run_id }}/artifacts?per_page=100"
$artifacts = (Invoke-RestMethod -Method Get -Uri $listUrl -Headers $headers).artifacts
foreach ($artifactName in $artifactNames) {
$artifact = $artifacts | Where-Object { $_.name -eq $artifactName } | Select-Object -First 1
if (-not $artifact) {
Write-Host "No artifact named '$artifactName' found on run ${{ steps.wait_ci.outputs.run_id }}."
continue
}
$deleteUrl = "https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$($artifact.id)"
Invoke-RestMethod -Method Delete -Uri $deleteUrl -Headers $headers | Out-Null
Write-Host "Deleted artifact '$artifactName' (id=$($artifact.id))."
}
notify:
needs: release
if: |
always() &&
!cancelled() &&
github.repository == 'pyrevitlabs/pyRevit' && (
(github.event_name == 'push' && github.ref_type == 'tag' && needs.release.result == 'success') ||
(github.event_name == 'workflow_dispatch' && inputs.notify_only == true)
)
runs-on: windows-2025
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_ref || github.ref }}
- name: Notify linked issues
continue-on-error: true
working-directory: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
Build__Channel: release
Build__NotifyUrl: ${{ github.event_name == 'workflow_dispatch' && inputs.release_url || needs.release.outputs.release_url }}
run: dotnet run -c Release -- notify