Repository navigation
136 lines (121 loc) · 4.41 KB
/
Copy pathrelease.yml
File metadata and controls
136 lines (121 loc) · 4.41 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
# Builds and publishes a CHDSharp release from a version tag:
# - six platform bundles (framework-dependent single-file CLI) attached to the GitHub release
# - the CHDSharp NuGet package
# - the docs/ folder synced to the GitHub wiki (and a Pages rebuild request)
#
# Assets are named CHDSharp_<os>-<arch>_v<version>.zip - the exact names the CLI's
# built-in update check (VersionCheckService) looks up via the GitHub releases API.
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
bundles:
name: Bundles & GitHub release
runs-on: ubuntu-latest
timeout-minutes: 60
env:
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "true"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Verify tag matches Directory.Build.props
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$version = [regex]::Match((Get-Content Directory.Build.props -Raw), "<Version>([^<]+)</Version>").Groups[1].Value
if ($tag -ne "v$version") { throw "Tag '$tag' does not match version 'v$version' in Directory.Build.props" }
Write-Host "Releasing v$version"
- name: Build release bundles
shell: pwsh
run: ./scripts/package-release.ps1 -OutputPath dist
- name: Create GitHub release and upload bundles
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
ver="${tag#v}"
if ! gh release view "$tag" >/dev/null 2>&1; then
gh release create "$tag" --title "CHDSharp v$ver" --notes-file WhatsNew.md
fi
gh release upload "$tag" dist/*.zip --clobber
gh release view "$tag" --json url,assets --jq '.url, (.assets[]?.name)'
nuget:
name: NuGet publish
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "true"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDKs (8.0, 9.0, 10.0)
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Pack and push to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
set -euo pipefail
version=$(grep -oP '(?<=<Version>)[^<]+' Directory.Build.props | head -1)
if curl -fsS -o /dev/null "https://api.nuget.org/v3-flatcontainer/chdsharp/$version/chdsharp.$version.nupkg"; then
echo "CHDSharp $version is already published - skipping"
exit 0
fi
if [ -z "${NUGET_API_KEY:-}" ]; then
echo "::error::NUGET_API_KEY secret is not set"
exit 1
fi
dotnet pack CHDSharpLib/CHDSharpLib.csproj -c Release
dotnet nuget push "CHDSharpLib/bin/Release/CHDSharp.$version.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json
wiki:
name: Wiki & Pages
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare wiki pages from docs/
shell: pwsh
run: ./scripts/prepare-wiki.ps1 -OutputPath wiki-content
- name: Push wiki pages
env:
WIKI_TOKEN: ${{ secrets.WIKI_TOKEN }}
run: |
set -euo pipefail
if [ -z "${WIKI_TOKEN:-}" ]; then
echo "::error::WIKI_TOKEN secret is not set"
exit 1
fi
git clone "https://x-access-token:${WIKI_TOKEN}@github.com/purelogiccode/CHDSharp.wiki.git" wiki-repo
cp -f wiki-content/*.md wiki-repo/
cd wiki-repo
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "Wiki is already up to date"
else
git commit -m "wiki: sync from docs/ (${GITHUB_REF_NAME})"
git push
fi
- name: Request Pages rebuild
env:
GH_TOKEN: ${{ secrets.WIKI_TOKEN }}
run: gh api -X POST repos/purelogiccode/CHDSharp/pages/builds --jq '.status'