Repository navigation
120 lines (103 loc) · 4.72 KB
/
Copy pathrelease.yml
File metadata and controls
120 lines (103 loc) · 4.72 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
name: Release
# Releases are tagged from main. Push a tag like v3.0.0 (or v3.0.0-beta.1 for a prerelease) to build every package at that version, test it, push it
# to NuGet and publish a GitHub release. Or run it by hand with a version, which creates the v<version> tag on the
# commit it built. The tag is the version - there is nothing to bump in the repo. A suffix after '-' marks both the
# NuGet packages and the GitHub release as prerelease. Toolchain pins match ci.yml - bump them together.
on:
push:
tags: [ 'v*' ]
workflow_dispatch:
inputs:
version:
description: 'Version (e.g. 3.0.0 or 3.0.0-beta.1) - creates the v<version> tag'
required: true
permissions:
id-token: write # required for NuGet trusted publishing (OIDC)
contents: write # creates the GitHub release (and the tag, when run by hand)
jobs:
release:
# same runner as ci.yml - see the note there
runs-on: xcode-27
steps:
- name: Version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
VERSION="${GITHUB_REF_NAME#v}"
fi
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Version '$VERSION' must look like 3.0.0 or 3.0.0-beta.1"; exit 1
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
echo "TAG=v$VERSION" >> "$GITHUB_ENV"
if [[ "$VERSION" == *-* ]]; then echo "PRERELEASE=--prerelease" >> "$GITHUB_ENV"; fi
- name: Checkout
uses: actions/checkout@v7
# Only a commit that is on main ships - a tag pushed from a feature branch, or a manual run from one, stops here
# before anything is built or published.
- name: Require main
run: |
git fetch --no-tags origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" FETCH_HEAD; then
echo "::error::$GITHUB_SHA is not on main - releases are tagged from main"; exit 1
fi
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
11.0.100
workloads: maui-ios, maui-android, maui-maccatalyst, macos, wasm-tools
- name: Select Xcode 27.1
run: sudo xcode-select -s /Applications/Xcode_27.1.app/Contents/Developer && xcodebuild -version
# Release packs on build (GeneratePackageOnBuild); Version overrides the 0.0.0-dev default in Directory.Build.props
- name: Build
run: dotnet build build.slnf /restore -m -property:Configuration=Release -property:Version="$VERSION"
# Nothing ships untested. The same Version as the build: the test project rebuilds the src projects, and
# GeneratePackageOnBuild would otherwise repack them as 0.0.0-dev beside the real packages.
- name: Test
run: dotnet test tests/Shiny.Net.HttpServer.Tests/Shiny.Net.HttpServer.Tests.csproj --configuration Release -property:Version="$VERSION" -p:TestingPlatformShowTestsFailure=true -p:TestingPlatformCaptureOutput=false
- name: Verify Native AOT
run: dotnet publish samples/Sample.Api/Sample.Api.csproj -r osx-arm64 --configuration Release -property:Version="$VERSION"
# Only this version's packages, so a stray dev-versioned pack can never be published.
- name: Collect packages
run: |
mkdir -p artifacts
find src -path '*/bin/Release/*' \( -name "*.$VERSION.nupkg" -o -name "*.$VERSION.snupkg" \) -exec cp {} artifacts/ \;
ls artifacts
- name: Publish Artifacts
uses: actions/upload-artifact@v7
with:
name: nugets
path: artifacts/*
if-no-files-found: error
- name: NuGet Login (OIDC)
id: nuget-login
uses: NuGet/login@v1
with:
user: aritchie
# NuGet first: the GitHub release only appears once the packages it points at are live. The .snupkg files are
# pushed alongside their .nupkg. --skip-duplicate so a re-run after a partial failure pushes only what is missing.
- name: Publish NuGets
run: >
dotnet nuget push "artifacts/*.nupkg"
--source https://api.nuget.org/v3/index.json
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}"
--skip-duplicate
- name: GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: >
gh release create "$TAG"
--repo "${{ github.repository }}"
--title "Shiny.Net.HttpServer $VERSION"
--notes "Release notes: https://shinylib.net/httpserver/release-notes/"
--generate-notes
--target "$GITHUB_SHA"
$PRERELEASE
# only after the packages and the GitHub release are out, so the published skills match a shipped version
skills:
needs: release
uses: ./.github/workflows/sync-skills.yml
secrets: inherit