forked from Checkmk/csm
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (110 loc) · 3.97 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (110 loc) · 3.97 KB
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
---
name: Release
on:
push:
tags:
- '*'
jobs:
preflight:
name: Preflight checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check that tag matches version in Cargo.toml
run: |
version=$(cargo pkgid | cut -d'#' -f2)
if [ "$version" != "${{ github.ref_name }}" ]; then
echo "Tag version does not match Cargo.toml version"
echo "Tag: ${{ github.ref_name }}, Cargo.toml: $version"
exit 1
fi
ci:
name: Run CI
needs: preflight
uses: ./.github/workflows/ci-reusable.yml
release:
needs: ci
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- runs-on: windows-latest
target: x86_64-pc-windows-msvc
- runs-on: windows-latest
target: i686-pc-windows-msvc
- runs-on: windows-latest
target: aarch64-pc-windows-msvc
- runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
- runs-on: ubuntu-latest
target: i686-unknown-linux-musl
- runs-on: ubuntu-latest
target: aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy, rustfmt
rustflags: ""
target: ${{ matrix.target }}
- name: Install cross
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
run: cargo install cross --git https://github.com/cross-rs/cross
# This step seems absolutely necessary for 'cross' to work.
- name: Clean build cache
run: cargo clean
- name: Build (Windows)
if: ${{ matrix.runs-on == 'windows-latest' }}
run: cargo build --release --all-features --target=${{ matrix.target }}
- name: Build (Linux, cross compile)
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
run: cross build --release --all-features --target=${{ matrix.target }}
- name: Create a zip (windows)
id: create-zip
if: ${{ matrix.runs-on == 'windows-latest' }}
run: |
mkdir release
cp LICENSE release/
cp target/${{ matrix.target }}/release/csm.exe release/
Compress-Archive -Path release/ -DestinationPath csm-${{ github.ref_name }}-${{ matrix.target }}.zip
- name: Create a tar.gz (linux)
id: create-tar
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
run: |
mkdir release
cp LICENSE release/
cp target/${{ matrix.target }}/release/csm release/
tar -czvf csm-${{ github.ref_name }}-${{ matrix.target }}.tar.gz release/
- name: Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
files: |
csm*.zip
csm*.tar.gz
test-release:
name: Post-release test
needs: release
runs-on: ${{ matrix.runs-on }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- runs-on: windows-latest
- runs-on: ubuntu-latest
steps:
- name: Try latest release (linux)
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
run: |
wget https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/csm-${{ github.ref_name }}-x86_64-unknown-linux-musl.tar.gz
tar -xvf csm-*.tar.gz
./release/csm --version
- name: Try latest release (windows)
if: ${{ matrix.runs-on == 'windows-latest' }}
run: |
Invoke-WebRequest -Uri https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/csm-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip -OutFile csm-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip
Expand-Archive -Path csm-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip -DestinationPath .
.\release\csm.exe --version