-
Notifications
You must be signed in to change notification settings - Fork 9
113 lines (103 loc) · 3.92 KB
/
create-release.yml
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
name: Create Release
on:
push:
tags:
- v*
jobs:
create-artifact:
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [ win-x64, linux-x64, linux-arm64, osx-x64 ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build artifact
shell: pwsh
run: |
$tag = '${{ github.event.ref }}'.Replace('refs/tags/', '')
$zipDirectory = "GetMoarFediverse-$($tag)"
mkdir $tag
mkdir artifact
$outputPath = Join-Path (Pwd) $zipDirectory
$srcPath = Join-Path (Pwd) src
$uid = sh -c 'id -u'
$gid = sh -c 'id -g'
docker run -v "$($outputPath):/var/output" -v "$($srcPath):/var/src" mcr.microsoft.com/dotnet/sdk:8.0.100-1-alpine3.18 ash -c "dotnet publish -r ${{ matrix.runtime }} --self-contained -p:PublishTrimmed=true -p:PublishSingleFile=true -c Release /var/src/GetMoarFediverse.csproj -o /var/output && chown -R $($uid):$($gid) /var/output"
Push-Location $outputPath
chmod +r *
chmod +x GetMoarFediverse || true
Pop-Location
if ('${{ matrix.runtime }}'.StartsWith('win-')) {
Compress-Archive -Path $zipDirectory -DestinationPath "artifact/GetMoarFediverse_${{ matrix.runtime }}.zip"
} else {
tar -czf artifact/GetMoarFediverse_${{ matrix.runtime }}.tgz $zipDirectory
}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}
path: artifact/*
create-release:
runs-on: ubuntu-latest
needs: [ create-artifact ]
steps:
- uses: actions/download-artifact@v4
with:
name: win-x64
path: artifacts/win-x64
- uses: actions/download-artifact@v4
with:
name: linux-x64
path: artifacts/linux-x64
- uses: actions/download-artifact@v4
with:
name: linux-arm64
path: artifacts/linux-arm64
- uses: actions/download-artifact@v4
with:
name: osx-x64
path: artifacts/osx-x64
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: |
artifacts/win-x64/*.zip
artifacts/linux-x64/*.tgz
artifacts/linux-arm64/*.tgz
artifacts/osx-x64/*.tgz
create-docker-image:
runs-on: ubuntu-latest
needs: [ create-release ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the Docker image
shell: pwsh
run: |
$version = '${{ github.event.ref }}'.Replace('refs/tags/', '').Replace('v', '')
$packageUrl = "ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}".ToLower()
$archs = "amd64", "arm64v8"
foreach ($arch in $archs) {
docker build -t "$($packageUrl):latest-$($arch)" --build-arg ARCH=$($arch) .
docker tag "$($packageUrl):latest-$($arch)" "$($packageUrl):$($version)-$($arch)"
docker push "$($packageUrl):latest-$($arch)"
docker push "$($packageUrl):$($version)-$($arch)"
}
docker manifest create `
"$($packageUrl):latest" `
--amend "$($packageUrl):latest-amd64" `
--amend "$($packageUrl):latest-arm64v8"
docker manifest create `
"$($packageUrl):$($version)" `
--amend "$($packageUrl):$($version)-amd64" `
--amend "$($packageUrl):$($version)-arm64v8"
docker manifest push "$($packageUrl):latest"
docker manifest push "$($packageUrl):$($version)"