-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (136 loc) · 5.01 KB
/
bin-release.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
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
name: 'Release ntr binary'
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
env:
BIN_CRATE_NAME: bin
LIB_NAME: ntr
jobs:
build-release:
needs: create-release
name: build-release
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: 1
strategy:
matrix:
build:
- linux musl x64
# - linux musl aarch64
- macos x64
# - macos aarch64
include:
- build: linux musl x64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
# - build: linux gnu aarch64
# os: ubuntu-latest
# rust: stable
# target: aarch64-unknown-linux-gnu
- build: macos x64
os: macos-latest
rust: stable
target: x86_64-apple-darwin
# - build: macos aarch64
# os: macos-latest
# rust: stable
# target: aarch64-apple-darwin
steps:
- name: Echo env variables
run: |
echo "BIN_CRATE_NAME: $BIN_CRATE_NAME"
echo "LIB_NAME: $LIB_NAME"
- name: Set release tag
run: |
if [ "$GITHUB_EVENT_NAME" == 'workflow_dispatch' ]; then
echo "RELEASE_TAG=main" >> "$GITHUB_ENV"
else
echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
fi
- name: Checkout repository
uses: actions/checkout@v3
# - name: Install Protoc
# uses: arduino/setup-protoc@v2
# with:
# repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
# - name: Add WASM target
# run: rustup target add wasm32-wasi
# - name: Install musl-tools
# if: matrix.os == 'ubuntu-latest'
# run: sudo apt-get install -y --no-install-recommends musl-tools
# # Workaround for <https://github.com/actions/virtual-environments/issues/2557>
# - name: Switch Xcode SDK
# if: runner.os == 'macos'
# run: |
# cat <<EOF >> "$GITHUB_ENV"
# SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
# EOF
- name: Build release binary
# run: cargo xtask ci cross ${{ matrix.target }}
run: cargo build -p "$BIN_CRATE_NAME" --release --target=${{ matrix.target }}
# this breaks on aarch64 and this if conditional isn't working for some reason: TODO: investigate
#- name: Strip release binary
# if: runner.target != 'aarch64-unknown-linux-musl' && runner.target != 'aarch64-apple-darwin'
# run: strip "target/${{ matrix.target }}/release/$BIN_CRATE_NAME"
- name: Create checksum
id: make-checksum
working-directory: ./target/${{ matrix.target }}/release
run: |
name="$BIN_CRATE_NAME-${{ matrix.target }}.sha256sum"
if [[ "$RUNNER_OS" != "macOS" ]]; then
sha256sum "$BIN_CRATE_NAME" > "${name}"
else
shasum -a 256 "$BIN_CRATE_NAME" > "${name}"
fi
echo "::set-output name=name::${name}"
- name: Tar release
id: make-artifact
working-directory: ./target/${{ matrix.target }}/release
run: |
name="$LIB_NAME-${{ matrix.target }}.tar.gz"
mv "$BIN_CRATE_NAME" "$LIB_NAME"
tar cvzf "${name}" "$LIB_NAME"
echo "::set-output name=name::${name}"
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/${{ steps.make-artifact.outputs.name }}
asset_name: ${{env.LIB_NAME}}-${{matrix.target}}.tar.gz
asset_content_type: application/octet-stream
- name: Upload checksum
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/${{ steps.make-checksum.outputs.name }}
asset_name: ${{env.LIB_NAME}}-${{matrix.target}}.sha256sum
asset_content_type: text/plain
create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: create_release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && '' || github.ref }}
release_name: ${{ github.event_name == 'workflow_dispatch' && 'main' || github.ref }}
draft: ${{ github.event_name == 'workflow_dispatch' }}
prerelease: false