-
Notifications
You must be signed in to change notification settings - Fork 5
186 lines (147 loc) · 4.96 KB
/
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Release
on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
defaults:
run:
working-directory: src
jobs:
init:
name: Initialize
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.version.outputs.product-version }}
steps:
- uses: actions/checkout@v3
- name: Get Version
id: version
working-directory: ./
run: |
productVersion=$(cat version.txt)
majorVersion=$(echo "$productVersion" | cut -d'.' -f1)
echo "product-version=$productVersion" >> $GITHUB_OUTPUT
echo "product-version-major=$majorVersion" >> $GITHUB_OUTPUT
test:
name: Test
runs-on: ubuntu-latest
needs: init
steps:
- name: Publish
run: |
echo "hi: ${{ needs.init.outputs.product-version }}"
echo "yo: ${{ needs.init.outputs.product-version-major }}"
exe:
name: Build executables
runs-on: ubuntu-latest
needs: init
strategy:
matrix:
rid:
- win-x64
- win-arm64
- osx-x64
- osx-arm64
- linux-x64
- linux-arm64
- linux-musl-x64
- linux-musl-arm64
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Install dependencies
working-directory: src/Valleysoft.Dredge
run: dotnet restore --runtime ${{ matrix.rid }}
- name: Publish
working-directory: src/Valleysoft.Dredge
run: dotnet publish -f net8.0 -c Release --no-restore -o ${{ github.workspace }}/publish --runtime ${{ matrix.rid }}
- name: Rename output
run: |
if [[ "${{ matrix.rid }}" == *"win"* ]]; then
dredgeExt=".exe"
else
dredgeExt=""
fi
exeName="dredge-${{ needs.init.outputs.product-version }}-${{ matrix.rid }}${dredgeExt}"
echo "EXE_NAME=${exeName}" >> $GITHUB_ENV
mv ${{ github.workspace }}/publish/dredge${dredgeExt} ${{ github.workspace }}/publish/${exeName}
rm ${{ github.workspace }}/publish/dredge.pdb
- name: Generate checksum
run: sha256sum ${EXE_NAME} >${EXE_NAME}.sha256sum
working-directory: ${{ github.workspace }}/publish
- name: Save build binaries
uses: actions/upload-artifact@v3
with:
name: dredge-binaries-${{ matrix.rid }}
path: ${{ github.workspace }}/publish
save-exes:
name: Save executables
needs: exe
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download build binaries
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}/publish
- name: Move all files
run: |
mv ${{ github.workspace }}/publish/dredge-binaries-*/* ${{ github.workspace }}/publish
rm -r ${{ github.workspace }}/publish/dredge-binaries-*
- name: Save build binaries
uses: actions/upload-artifact@v3
with:
name: dredge-binaries
path: ${{ github.workspace }}/publish
nuget:
name: Publish NuGet Package
runs-on: ubuntu-latest
needs: save-exes
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore Valleysoft.Dredge
- name: Pack
env:
PACKAGE_VERSION: ${{ needs.init.outputs.product-version }}
run: dotnet pack -c Release -p:Version=$PACKAGE_VERSION Valleysoft.Dredge -p:IsPack=true
# - name: Publish Package
# run: dotnet nuget push "Valleysoft.Dredge/bin/Release/*.nupkg" -k ${{secrets.NUGET_ORG_API_KEY}} -s https://nuget.org
docker:
name: Publish Docker Image
runs-on: ubuntu-latest
needs: nuget
steps:
- uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./src
platforms: linux/amd64,linux/arm64
push: false
tags: >
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.init.outputs.product-version }},
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.init.outputs.product-version-major }},
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
build-args: |
PACKAGE_VERSION=${{ needs.init.outputs.product-version }}