-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (146 loc) · 6.71 KB
/
github-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
name: GitHub Release
env:
ARTEFACTS_DIR: "_artefacts"
CARGO_TERM_COLOR: always
permissions:
contents: write
on:
push:
tags: [ "v[0-9]+.[0-9]+.[0-9]+*" ]
# TODO Remove this trigger, once we have sorted out release for the various targets
workflow_dispatch:
jobs:
release:
name: Release
# Workflow strategy supports multiple targets on multiple runners
strategy:
fail-fast: false
matrix:
job:
# Linux
# - { target: aarch64-unknown-linux-gnu , runner: ubuntu-20.04, cross: true, can_fail: false }
# - { target: i686-unknown-linux-gnu , runner: ubuntu-20.04, cross: true, can_fail: false }
- { target: x86_64-unknown-linux-gnu , runner: ubuntu-20.04, cross: true, can_fail: false }
# - { target: arm-unknown-linux-gnueabihf , runner: ubuntu-20.04, cross: true, can_fail: false }
# - { target: arm-unknown-linux-musleabihf, runner: ubuntu-20.04, cross: true, can_fail: false }
# - { target: i686-unknown-linux-musl , runner: ubuntu-20.04, cross: true, can_fail: false }
# - { target: x86_64-unknown-linux-musl , runner: ubuntu-20.04, cross: true, can_fail: false }
# macOS
- { target: x86_64-apple-darwin , runner: macos-10.15, cross: false, can_fail: false }
# Windows
# # TODO https://github.com/kafkesc/ksunami/issues/39
# - { target: i686-pc-windows-msvc , runner: windows-2019, cross: false, can_fail: true, arch: i686 }
# - { target: x86_64-pc-windows-gnu , runner: windows-2019, cross: false, can_fail: true, arch: x86_64 }
# - { target: x86_64-pc-windows-msvc , runner: windows-2019, cross: false, can_fail: true, arch: x86_64 }
runs-on: ${{ matrix.job.runner }}
continue-on-error: ${{ matrix.job.can_fail }}
steps:
- name: Check-out
uses: actions/checkout@v4
- name: Dependencies
shell: bash
run: |
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf ;;
aarch64-unknown-linux-gnu) sudo apt-get -y install gcc-aarch64-linux-gnu g++-arm-linux-gnueabihf ;;
esac
- name: Project info as env-var
shell: bash
run: |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
# # TODO https://github.com/kafkesc/ksunami/issues/39
# - name: Deps (Windows)
# if: ${{ startsWith(matrix.job.runner, 'windows') }}
# run: >-
# choco install visualstudio2019enterprise --package-parameters "
# --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
# --add Microsoft.VisualStudio.Component.Windows10SDK
# --add Microsoft.VisualStudio.Component.Windows10SDK.19041
# --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core
# --add Microsoft.VisualStudio.Component.VC.CMake.Project
# --add Microsoft.VisualStudio.Component.VC.CoreBuildTools
# --add Microsoft.VisualStudio.Component.VC.ATLMFC
# --add Microsoft.VisualStudio.Component.Roslyn.Compiler"
# ; choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
# # TODO https://github.com/kafkesc/ksunami/issues/39
# - name: Envs - MSVC (Windows)
# if: ${{ startsWith(matrix.job.runner, 'windows') }}
# uses: ilammy/msvc-dev-cmd@v1
# with:
# arch: ${{ matrix.job.arch }}
# vsversion: 2019
# # TODO https://github.com/kafkesc/ksunami/issues/39
# - name: Envs - WindowsSdkVerBinPath (Windows)
# if: ${{ startsWith(matrix.job.runner, 'windows') }}
# uses: myci-actions/export-env-var-powershell@1
# with:
# name: PATH
# value: $env:PATH;$env:WindowsSdkVerBinPath\x86;$env:WindowsSdkVerBinPath\x64
- name: Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.job.target }}
profile: minimal
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.cross }}
command: build
args: --locked --release --target=${{ matrix.job.target }}
- name: Artefact
id: artefact
shell: bash
run: |
# Figure out if the binary has a suffix (Windows!)
EXE_SUFFIX=""
case ${{ matrix.job.target }} in
*-pc-windows-*) EXE_SUFFIX=".exe" ;;
esac;
# Setup paths
BIN_NAME="${{ env.PROJECT_NAME }}${EXE_SUFFIX}"
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
# Let subsequent steps know where to find the binary
echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT
- name: Package
id: package
shell: bash
run: |
# Figure out the tarball suffix (Windows!)
PKG_SUFFIX=".tar.gz"
case ${{ matrix.job.target }} in
*-pc-windows-*) PKG_SUFFIX=".zip" ;;
esac
# Composing final PKG_NAME
PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}
PKG_NAME=${PKG_BASENAME}${PKG_SUFFIX}
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT
PKG_STAGING="${{ env.ARTEFACTS_DIR }}/package"
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
mkdir -p "${ARCHIVE_DIR}"
# Binary
cp "${{ steps.artefact.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
# README, LICENSE-* and CHANGELOG files
cp "README.md" "LICENSE-APACHE" "LICENSE-MIT" "CHANGELOG.md" "$ARCHIVE_DIR"
# base compressed package
pushd "${PKG_STAGING}/" >/dev/null
case ${{ matrix.job.target }} in
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
esac;
popd >/dev/null
# Let subsequent steps know where to find the compressed package
echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
- name: Release
id: release
uses: softprops/action-gh-release@v1
with:
name: v${{ env.PROJECT_VERSION }}
tag_name: v${{ env.PROJECT_VERSION }}
files: |
${{ steps.package.outputs.PKG_PATH }}