-
Notifications
You must be signed in to change notification settings - Fork 1
177 lines (152 loc) · 5.88 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
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
name: Release CI
on:
push:
tags:
- v*.*.*
env:
RELEASE_VERSION: $(echo $GITHUB_REF_NAME | cut -d'v' -f2)
DOTNET_VERSION: 6.0
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [win-x64, win-x86, linux-x64, linux-musl-x64, linux-arm, linux-arm64, osx-x64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}.x
- name: Build tldr-sharp
run: |
dotnet publish -c Release --self-contained false -o 'publish/${{ matrix.runtime }}' -r '${{ matrix.runtime }}'
- name: Cache Build
uses: actions/cache/save@v3
with:
path: 'publish/${{ matrix.runtime }}'
key: ${{ runner.os }}-${{ github.sha }}-build-${{ matrix.runtime }}
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '${{ env.DOTNET_VERSION }}.x'
- name: Restore cached build
uses: actions/cache/restore@v3
with:
path: publish/linux-x64
key: ${{ runner.os }}-${{ github.sha }}-build-linux-x64
- run: bash scripts/test.sh
create_setup:
runs-on: ubuntu-latest
needs: [build, test]
strategy:
matrix:
runtime: [win-x64, win-x86]
steps:
- uses: actions/checkout@v3
- name: Restore cached build
uses: actions/cache/restore@v3
with:
path: 'publish/${{ matrix.runtime }}'
key: ${{ runner.os }}-${{ github.sha }}-build-${{ matrix.runtime }}
- name: Copy build output
run: |
cp -r 'publish/${{ matrix.runtime }}' scripts/windows/release
- name: Download EnVar plugin for NSIS
uses: carlosperate/download-file-action@v2
with:
file-url: https://nsis.sourceforge.io/mediawiki/images/7/7f/EnVar_plugin.zip
file-name: envar_plugin.zip
location: ${{ github.workspace }}
sha256: 39e94847ef0209c5cd93b735c3f560131c192a1136c96eddf643944e69c03b92
- name: Extract EnVar plugin
run: unzip '${{ github.workspace }}/envar_plugin.zip' -d '${{ github.workspace }}/NSIS_Plugins'
- name: Install makensis
run: |
sudo apt-get update
sudo apt-get install -y nsis nsis-pluginapi
- name: Set Plugin permissions
run: sudo chown -R $(whoami) /usr/share/nsis/Plugins/
- name: Set tldr-sharp version
run: sed -i "s/VERSION_PLACEHOLDER/${{ env.RELEASE_VERSION }}.0/g" 'scripts/windows/install.nsi'
- name: Create nsis installer
uses: joncloud/makensis-action@v4
with:
script-file: scripts/windows/install.nsi
additional-plugin-paths: '${{ github.workspace }}/NSIS_Plugins/Plugins'
- name: Rename installer
run: |
mv 'scripts/windows/tldr-sharp_setup.exe' 'scripts/windows/tldr-sharp_${{ matrix.runtime }}.exe'
- name: Add to Release
uses: softprops/action-gh-release@v1
with:
files: 'scripts/windows/tldr-sharp_${{ matrix.runtime }}.exe'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create_deb:
runs-on: ubuntu-latest
needs: [build, test]
strategy:
matrix:
runtime: [linux-x64]
steps:
- uses: actions/checkout@v3
- name: Restore cached build
uses: actions/cache/restore@v3
with:
path: 'publish/${{ matrix.runtime }}'
key: ${{ runner.os }}-${{ github.sha }}-build-${{ matrix.runtime }}
- name: Prepare directory
run: |
pushd 'publish/${{ matrix.runtime }}'
find . -not -name '*.exe' -type f -exec install -Dm 644 '{}' '${{ github.workspace }}/.debpkg/usr/lib/tldr-sharp/{}' \;
find . -name '*.exe' -type f -exec install -Dm 755 '{}' '${{ github.workspace }}/.debpkg/usr/lib/tldr-sharp/{}' \;
popd
install -dm755 .debpkg/usr/bin
ln -s /usr/lib/tldr-sharp/tldr-sharp .debpkg/usr/bin/tldr-sharp
install -Dm644 scripts/debian/control .debpkg/DEBIAN/control
install -Dm755 scripts/debian/postinst .debpkg/DEBIAN/postinst
install -Dm755 scripts/debian/prerm .debpkg/DEBIAN/prerm
sed -i "s/VERSION_PLACEHOLDER/${{ env.RELEASE_VERSION }}/g" .debpkg/DEBIAN/control
- name: Build Debian package
run: fakeroot dpkg-deb --build .debpkg 'tldr-sharp_${{ matrix.runtime }}.deb'
- name: Add to Release
uses: softprops/action-gh-release@v1
with:
files: tldr-sharp_${{ matrix.runtime }}.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
create_archives:
runs-on: ubuntu-latest
needs: [build,test]
strategy:
matrix:
runtime: [win-x64, win-x86, linux-x64, linux-musl-x64, linux-arm, linux-arm64, osx-x64]
steps:
- uses: actions/checkout@v3
- name: Restore cached build
uses: actions/cache/restore@v3
with:
path: 'publish/${{ matrix.runtime }}'
key: ${{ runner.os }}-${{ github.sha }}-build-${{ matrix.runtime }}
- name: Create tar archive
if: ${{ startsWith( matrix.runtime, 'linux') }}
run: tar czf tldr-sharp_${{ matrix.runtime }}.tar.gz -C 'publish/${{ matrix.runtime }}' .
- name: Create zip archive
if: ${{ !startsWith( matrix.runtime, 'linux') }}
run: |
pushd publish/${{ matrix.runtime }}
zip -r '${{ github.workspace }}/tldr-sharp_${{ matrix.runtime }}.zip' .
popd
- name: Add to Release
uses: softprops/action-gh-release@v1
with:
files: |
tldr-sharp_${{ matrix.runtime }}.${{ startsWith( matrix.runtime, 'linux') && 'tar.gz' || 'zip' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}