Repository navigation
166 lines (143 loc) · 5.06 KB
/
Copy pathrelease.yml
File metadata and controls
166 lines (143 loc) · 5.06 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
name: Release
# A tag vX.Y.Z publishes the 7 NuGet packages, the two container images and the GitHub Release (spec 009, AC-5).
# Nothing is published unless the CI is green on the tagged commit, and the `release` environment asks a maintainer
# to approve the publication.
on:
push:
tags: ['v*']
permissions:
contents: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
packages:
name: NuGet packages
needs: ci
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write # NuGet trusted publishing (D-170)
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
# Packing in Release embeds the Vue panel in PythonScriptRunner.Dashboard (D-155).
- uses: actions/setup-node@v7
with:
node-version-file: panel/.nvmrc
cache: npm
cache-dependency-path: panel/package-lock.json
- name: Pack
run: dotnet pack PythonScriptRunner.slnx --configuration Release --output artifacts/packages
- name: Check the version
run: |
expected="${GITHUB_REF_NAME#v}"
for package in artifacts/packages/*.nupkg; do
case "$package" in
*".$expected.nupkg") ;;
*) echo "$package does not have version $expected"; exit 1 ;;
esac
done
test "$(ls artifacts/packages/*.nupkg | wc -l)" -eq 7
- name: Log in to NuGet
id: nuget
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
# The symbol packages (.snupkg) next to each .nupkg are pushed with it.
- name: Push
run: >-
dotnet nuget push "artifacts/packages/*.nupkg"
--api-key "${{ steps.nuget.outputs.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json
--skip-duplicate
- uses: actions/upload-artifact@v7
with:
name: packages
path: artifacts/packages/
images:
name: Container images (${{ matrix.image }})
needs: ci
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: psr-worker
dockerfile: hosts/PythonScriptRunner.WorkerHost/Dockerfile
- image: psr-dashboard
dockerfile: hosts/PythonScriptRunner.DashboardHost/Dockerfile
steps:
- uses: actions/checkout@v7
# The build stages compile on the runner's platform; only the final stage runs for arm64 (emulated).
- uses: docker/setup-qemu-action@v4
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/scriptrunnerkit/${{ matrix.image }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}},enable=${{ !contains(github.ref_name, '-') }}
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
- uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: VERSION=${{ steps.meta.outputs.version }}
sbom: true
provenance: mode=max
cache-from: type=gha,scope=release-${{ matrix.image }}
cache-to: type=gha,scope=release-${{ matrix.image }},mode=max
github-release:
name: GitHub Release
needs: [packages, images]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: packages
path: artifacts/packages
# The notes are the CHANGELOG section of the version, which also carries the compatibility matrix (D-178).
- name: Release notes
run: |
version="${GITHUB_REF_NAME#v}"
awk -v v="$version" '
index($0, "## [" v "]") == 1 { found = 1; next }
found && index($0, "## [") == 1 { exit }
found { print }
' CHANGELOG.md > notes.md
test -s notes.md || { echo "CHANGELOG.md has no section for $version"; exit 1; }
- name: Create the release
env:
GH_TOKEN: ${{ github.token }}
run: |
prerelease=$([[ "$GITHUB_REF_NAME" == *-* ]] && echo --prerelease || true)
gh release create "$GITHUB_REF_NAME" artifacts/packages/*.nupkg \
--title "PythonScriptRunner ${GITHUB_REF_NAME#v}" --notes-file notes.md --verify-tag $prerelease