Repository navigation
98 lines (98 loc) · 4.51 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (98 loc) · 4.51 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
name: Release
on:
workflow_dispatch:
permissions:
contents: read
jobs:
tests:
name: Build and Tests
uses: ./.github/workflows/build-and-tests.yml
publish:
name: Publish ${{ matrix.runtime }}
needs: tests
runs-on: ubuntu-24.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
runtime: [linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, osx-arm64]
steps:
- name: Download source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Publish server and CLI
env:
RUNTIME: ${{ matrix.runtime }}
run: |
dotnet publish src/KeyLoad/KeyLoad.csproj --configuration Release --runtime "$RUNTIME" --self-contained true -warnaserror --output artifacts/publish/server
dotnet publish src/KeyLoad.Cli/KeyLoad.Cli.csproj --configuration Release --runtime "$RUNTIME" --self-contained true -warnaserror --output artifacts/publish/cli
tar -czf "artifacts/keyload-$RUNTIME.tar.gz" -C artifacts/publish server cli
- name: Save applications
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: keyload-${{ matrix.runtime }}
path: artifacts/keyload-${{ matrix.runtime }}.tar.gz
if-no-files-found: error
server-image:
name: Publish server container image
needs: tests
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: read
packages: write
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_REPOSITORY: managedcode/keyload
steps:
- name: Download source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Sign in to GitHub Container Registry
env:
REGISTRY_TOKEN: ${{ github.token }}
run: printf '%s' "$REGISTRY_TOKEN" | docker login "$IMAGE_REGISTRY" --username "$GITHUB_ACTOR" --password-stdin
- name: Publish the server image with commit and latest tags
run: dotnet publish src/KeyLoad/KeyLoad.csproj /t:PublishContainer --configuration Release --runtime linux-x64 -warnaserror -p:ContainerRegistry="$IMAGE_REGISTRY" -p:ContainerRepository="$IMAGE_REPOSITORY" "-p:ContainerImageTags=\"$GITHUB_SHA;latest\""
- name: Record the published image digest
shell: bash
run: |
image="$IMAGE_REGISTRY/$IMAGE_REPOSITORY"
digest=$(docker buildx imagetools inspect "$image:$GITHUB_SHA" --format '{{json .Manifest}}' | jq -er '.digest')
latest=$(docker buildx imagetools inspect "$image:latest" --format '{{json .Manifest}}' | jq -er '.digest')
[[ "$digest" =~ ^sha256:[0-9a-f]{64}$ && "$digest" == "$latest" ]]
mkdir -p artifacts
printf '%s:%s@%s\n' "$image" "$GITHUB_SHA" "$digest" > artifacts/keyload-server-image.txt
printf 'Server image: `%s:%s@%s` (also tagged `latest`)\n' "$image" "$GITHUB_SHA" "$digest" >> "$GITHUB_STEP_SUMMARY"
- name: Save the image reference
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: keyload-server-image
path: artifacts/keyload-server-image.txt
if-no-files-found: error
benchmark-image:
name: Build benchmark Docker image
needs: tests
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- name: Download source code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Build Docker image
run: dotnet publish benchmarks/KeyLoad.ComparisonHost/KeyLoad.ComparisonHost.csproj /t:PublishContainer --configuration Release --runtime linux-x64 -warnaserror -p:ContainerRepository="keyload/benchmarks" -p:ContainerImageTag="$GITHUB_SHA" -p:ContainerArchiveOutputPath="$GITHUB_WORKSPACE/keyload-benchmarks.tar"
- name: Save Docker image
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: keyload-docker-benchmarks
path: keyload-benchmarks.tar
if-no-files-found: error