-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (111 loc) · 3.56 KB
/
Copy pathrelease.yml
File metadata and controls
131 lines (111 loc) · 3.56 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
name: Release
on:
push:
branches:
- "**"
workflow_dispatch:
permissions:
contents: write
env:
DOTNET_VERSION: "10.0.x"
PROJECT_PATH: GitRekt/GitRekt.csproj
jobs:
publish:
name: Publish ${{ matrix.rid }}
if: github.ref_name == github.event.repository.default_branch
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- rid: win-x64
os: windows-latest
archive: zip
- rid: linux-x64
os: ubuntu-latest
archive: tar.gz
- rid: osx-x64
os: macos-15-intel
archive: tar.gz
- rid: osx-arm64
os: macos-15
archive: tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Linux NativeAOT prerequisites
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
- name: Publish NativeAOT executable
shell: pwsh
run: |
$rid = '${{ matrix.rid }}'
$publishDir = Join-Path $PWD "publish/$rid"
$isWindowsRid = $rid -like 'win-*'
dotnet publish $env:PROJECT_PATH `
--configuration Release `
--runtime $rid `
--self-contained true `
-p:PublishAot=true `
-p:PublishSingleFile=true `
-p:DebugType=None `
-p:DebugSymbols=false `
--output $publishDir
$exeName = if ($isWindowsRid) { 'GitRekt.exe' } else { 'GitRekt' }
$exePath = Join-Path $publishDir $exeName
if (!(Test-Path -LiteralPath $exePath)) {
throw "Expected NativeAOT executable was not produced: $exePath"
}
if (!$isWindowsRid) {
chmod +x $exePath
}
- name: Package executable
shell: pwsh
run: |
$rid = '${{ matrix.rid }}'
$archiveType = '${{ matrix.archive }}'
$publishDir = Join-Path $PWD "publish/$rid"
$distDir = Join-Path $PWD "dist"
New-Item -ItemType Directory -Force -Path $distDir | Out-Null
if ($archiveType -eq 'zip') {
Compress-Archive `
-Path (Join-Path $publishDir 'GitRekt.exe') `
-DestinationPath (Join-Path $distDir "gitrekt-$rid.zip") `
-Force
} else {
tar -czf (Join-Path $distDir "gitrekt-$rid.tar.gz") -C $publishDir GitRekt
}
- name: Upload packaged executable
uses: actions/upload-artifact@v4
with:
name: gitrekt-${{ matrix.rid }}
path: dist/*
if-no-files-found: error
release:
name: Create GitHub release
if: github.ref_name == github.event.repository.default_branch
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download packaged executables
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: gitrekt-${{ github.run_number }}.${{ github.run_attempt }}
run: |
set -euo pipefail
gh release create "$TAG_NAME" dist/* \
--title "GitRekt $TAG_NAME" \
--notes "Automated NativeAOT release for commit $GITHUB_SHA." \
--target "$GITHUB_SHA" \
--latest