-
-
Notifications
You must be signed in to change notification settings - Fork 18
133 lines (124 loc) · 4.55 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
name: release
on:
push:
tags:
- 'v*'
env:
PROJECT_NAME: 'tone'
PROJECT_PATH: 'tone/tone.csproj'
PROJECT_OUTPUT_PATH: ${{ github.workspace }}/output/
DOTNET_VERSION: '6.0.405'
DOTNET_FRAMEWORK: 'net6.0'
jobs:
release:
name: Release
strategy:
matrix:
kind: [
'linux',
'linux-musl-x64',
'linux-arm',
'linux-arm64',
'windows',
'macOS',
'macOS-arm'
]
include:
- kind: linux
os: ubuntu-latest
target: linux-x64
- kind: linux-musl-x64
os: ubuntu-latest
target: linux-musl-x64 # for docker
- kind: linux-arm
os: ubuntu-latest
target: linux-arm
- kind: linux-musl-arm
os: ubuntu-latest
target: linux-musl-arm
- kind: linux-arm64
os: ubuntu-latest
target: linux-arm64
- kind: linux-musl-arm64
os: ubuntu-latest
target: linux-musl-arm64
- kind: windows
os: windows-latest
target: win-x64
- kind: macOS
os: macos-latest
target: osx-x64
- kind: macOS-arm
os: macos-latest
target: osx-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
source-url: "https://nuget.pkg.github.com/sandreas/index.json"
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Get version
id: version
uses: battila7/get-version-action@v2
- name: Build
id: build
shell: bash
run: |
release_name="${{ env.PROJECT_NAME }}-${{ steps.version.outputs.version-without-v }}-${{ matrix.target }}"
release_notes="$(sed 's/%/%25/g;s/\r/%0D/g;' ${{ env.PROJECT_NAME }}/doc/release/release-notes-${{ steps.version.outputs.version }}.md | sed ':a;N;$!ba;s/\n/%0A/g')"
echo "::set-output name=release_notes::$release_notes"
sed -i.bak "s/<TargetFramework>net6.0<\/TargetFramework>/<TargetFramework>${{ env.DOTNET_FRAMEWORK }}<\/TargetFramework>/g" ${{ env.PROJECT_PATH }}
if [ "${{ matrix.target }}" == "osx-arm64" ]; then
dotnet publish ${{ env.PROJECT_PATH }} --framework ${{ env.DOTNET_FRAMEWORK }} --runtime "${{ matrix.target }}" -c Release -p:EnableCompressionInSingleFile=false -p:PublishSingleFile=true --self-contained true -p:PublishReadyToRun=true -p:PublishTrimmed=true -o "$release_name"
else
dotnet publish ${{ env.PROJECT_PATH }} --framework ${{ env.DOTNET_FRAMEWORK }} --runtime "${{ matrix.target }}" -c Release -p:PublishSingleFile=true --self-contained true -p:PublishReadyToRun=true -p:PublishTrimmed=true -o "$release_name"
fi
if [ "${{ matrix.target }}" == "win-x64" ]; then
7z a -tzip "${release_name}.zip" "./${release_name}/tone.exe"
else
tar czvf "${release_name}.tar.gz" "$release_name/tone"
fi
rm -r "$release_name"
- name: Publish
uses: softprops/action-gh-release@v1
with:
files: "${{ env.PROJECT_NAME }}-${{ steps.version.outputs.version-without-v }}-${{ matrix.target }}*"
body: "${{ steps.build.outputs.release_notes }}"
prerelease: endsWith(github.ref, 'prerelease')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
needs: release
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
file: tone/Dockerfile.release
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
#platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: true
tags: sandreas/tone:${{ github.ref_name }}
build-args: |
REF_NAME=${{ github.ref_name }}