Repository navigation
96 lines (91 loc) · 3.93 KB
/
Copy pathcli-release.yml
File metadata and controls
96 lines (91 loc) · 3.93 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
name: sw-serverless CLI release
# Publishes the sw-serverless command as self-contained binaries on a GitHub release: nothing needs .NET
# installed to run them. Never run by hand or by a tag: the CI run that publishes this repository
# calls it with the version it computed (determine-semver: the next patch from the git tags, the
# run number for a prerelease), so the CLI carries the version of the release it ships with.
# a release, 10.0.61 cli-v10.0.61 the latest release
# a prerelease, 10.0.61-releases-r10-0-staging.121 cli-v10.0.61-stg.121 a pre-release, to try out
# Called by nuget-publish.yml, after the packages are published.
on:
workflow_call:
inputs:
version:
description: "The version the calling run computed"
type: string
required: true
permissions:
contents: write
jobs:
channel:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.channel.outputs.version }}
prerelease: ${{ steps.channel.outputs.prerelease }}
steps:
- name: Channel
id: channel
env:
VERSION: ${{ inputs.version }}
run: |
v="$VERSION"
if [[ "$v" == *-* ]]; then
# A prerelease names its branch and run: 10.0.61-releases-r10-0-staging.121 is 10.0.61-stg.121.
v="${v%%-*}-stg.${v##*.}"
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
echo "version=$v" >> "$GITHUB_OUTPUT"
build:
needs: channel
runs-on: ubuntu-latest
strategy:
matrix:
rid: [linux-x64, linux-arm64, linux-musl-x64, linux-musl-arm64, osx-x64, osx-arm64, win-x64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: "10.0.x"
- name: Publish
run: >
dotnet publish SW.Serverless.Installer -c Release -r ${{ matrix.rid }} --self-contained
-p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none
-p:Version=${{ needs.channel.outputs.version }} -o out
- name: Package
run: |
mkdir -p dist
cp README.md LICENSE out/ 2>/dev/null || true
if [[ "${{ matrix.rid }}" == win-* ]]; then
(cd out && zip -q -r ../dist/sw-serverless-${{ matrix.rid }}.zip .)
else
tar -czf dist/sw-serverless-${{ matrix.rid }}.tar.gz -C out .
fi
- uses: actions/upload-artifact@v4
with:
name: sw-serverless-${{ matrix.rid }}
path: dist/*
release:
needs: [channel, build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Checksums
run: cd dist && sha256sum * > SHA256SUMS && cat SHA256SUMS
- name: Release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
v="${{ needs.channel.outputs.version }}"
install="curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/scripts/install-cli.sh"
if [ "${{ needs.channel.outputs.prerelease }}" = "true" ]; then
gh release create "cli-v$v" dist/* --title "sw-serverless CLI $v (pre-release)" --target "${{ github.sha }}" --prerelease \
--notes "A pre-release of the sw-serverless command, built from ${{ github.ref_name }}, to try out. Install: $install | SW_SERVERLESS_VERSION=$v sh — or download the archive for your platform and check it against SHA256SUMS."
else
gh release create "cli-v$v" dist/* --title "sw-serverless CLI $v" --target "${{ github.sha }}" --latest \
--notes "The sw-serverless command, self-contained for each platform. Install: $install | sh — or download the archive for your platform and check it against SHA256SUMS."
fi