Repository navigation
126 lines (111 loc) · 3.84 KB
/
Copy pathrelease.yml
File metadata and controls
126 lines (111 loc) · 3.84 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
concurrency:
group: release-rustenv
cancel-in-progress: false
jobs:
prepare:
name: Create draft release
runs-on: [self-hosted, s31]
steps:
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
build:
name: Build - ${{ matrix.target }}
needs: prepare
runs-on: ${{ fromJSON(matrix.runner) }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
runner: '["self-hosted","s31"]'
target: x86_64-unknown-linux-gnu
asset_name: rustenv-linux-x64
cross_arm64: false
- os: linux
runner: '["self-hosted","s31"]'
target: aarch64-unknown-linux-gnu
asset_name: rustenv-linux-arm64
cross_arm64: true
- os: macos
runner: '["self-hosted","macOS","s11"]'
target: x86_64-apple-darwin
asset_name: rustenv-darwin-x64
cross_arm64: false
- os: macos
runner: '["self-hosted","macOS","s11"]'
target: aarch64-apple-darwin
asset_name: rustenv-darwin-arm64
cross_arm64: false
- os: windows
runner: '["self-hosted","Windows","s18"]'
target: x86_64-pc-windows-msvc
asset_name: rustenv-win32-x64.exe
cross_arm64: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Ensure rustup in PATH (Unix)
if: runner.os != 'Windows'
run: |
if [ ! -x "$HOME/.cargo/bin/rustup" ]; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail https://sh.rustup.rs | sh -s -- --default-toolchain none -y --no-modify-path
fi
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Ensure rustup in PATH (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
if [ -x "$USERPROFILE/.cargo/bin/rustup.exe" ]; then
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
fi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install arm64 cross-linker (Linux)
if: matrix.cross_arm64
run: |
if ! command -v aarch64-linux-gnu-gcc >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross
fi
- name: Build binary (Standard)
if: ${{ !matrix.cross_arm64 }}
run: cargo build --target ${{ matrix.target }} --release
- name: Build binary (Linux arm64)
if: matrix.cross_arm64
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
run: cargo build --target ${{ matrix.target }} --release
- name: Prepare asset (Windows)
if: matrix.os == 'windows'
run: Move-Item -Force "target\${{ matrix.target }}\release\rustenv.exe" "${{ matrix.asset_name }}"
- name: Prepare asset (Unix)
if: matrix.os != 'windows'
run: mv -f "target/${{ matrix.target }}/release/rustenv" "${{ matrix.asset_name }}"
- name: Upload asset to draft release
uses: softprops/action-gh-release@v2
with:
draft: true
fail_on_unmatched_files: true
files: ${{ matrix.asset_name }}
publish:
name: Publish release
needs: build
runs-on: [self-hosted, s31]
steps:
- name: Publish release
uses: softprops/action-gh-release@v2
with:
draft: false
make_latest: true