-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (101 loc) · 3.42 KB
/
ci.yaml
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
on: [push, pull_request]
name: build
jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
rust: nightly
target: x86_64-unknown-linux-musl
archive-name: hit_course-linux.tar.gz
- build: macos
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
archive-name: hit_course-macos.tar.gz
- build: windows
os: windows-2019
rust: nightly-x86_64-msvc
target: x86_64-pc-windows-msvc
archive-name: hit_course-windows.7z
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: install openssl-tools
if: matrix.build == 'linux'
run: |
sudo apt-get update
sudo apt-get install libssl-dev cmake pkg-config musl-tools
- name: Build binary
run: |
cargo build --release --target ${{ matrix.target }}
cargo build --example req_auth --release --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1
- name: Strip binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: |
strip "target/${{ matrix.target }}/release/hit_course"
- name: Build archive
shell: bash
run: |
mkdir archive
cd archive
if [ "${{ matrix.build }}" = "windows" ]; then
cp "../target/${{ matrix.target }}/release/hit_course.exe" ./hit_course.exe
cp "../target/${{ matrix.target }}/release/examples/req_auth.exe" ./req_auth.exe
7z a "${{ matrix.archive-name }}" hit_course.exe req_auth.exe
else
cp "../target/${{ matrix.target }}/release/hit_course" ./hit_course
cp "../target/${{ matrix.target }}/release/examples/req_auth" ./req_auth
tar -czf "${{ matrix.archive-name }}" hit_course req_auth
fi
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive-name }}
path: archive/${{ matrix.archive-name }}
release:
name: Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/main') }}
needs: [build]
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/download-artifact@v4
- name: Display structure of downloaded files
run: ls -R
- name: pwd
run: pwd
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-path: 'wheels-*/*'
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
hit_course-linux.tar.gz/hit_course-linux.tar.gz
hit_course-macos.tar.gz/hit_course-macos.tar.gz
hit_course-windows.7z/hit_course-windows.7z
draft: true
fail_on_unmatched_files: true