-
-
Notifications
You must be signed in to change notification settings - Fork 119
151 lines (128 loc) · 4.35 KB
/
cd.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
name: Continuous Deployment
on:
push:
branches: [main]
env:
CARGO_TERM_COLOR: always
# Name of the crate from Cargo.toml
# used to rename and upload the binaries
PROJ_NAME: fj-app
# This lets our app know it's an "official" release. Otherwise we would get
# a version number like "fj-app 0.8.0 (8cb928bb, unreleased)"
FJ_OFFICIAL_RELEASE: 1
defaults:
run:
shell: bash
jobs:
binaries:
name: Binaries
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
- { target: x86_64-apple-darwin, os: macOS-latest }
- { target: aarch64-apple-darwin, os: macOS-latest }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Toolchain
uses: oxidecomputer/actions-rs_toolchain@oxide/master
# see https://github.com/actions-rs/toolchain/pull/209
# uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
target: ${{ matrix.target }}
- name: Cache
uses: Swatinem/rust-cache@v1
with:
key: ${{ matrix.target }}
- name: Binaries | Compile
uses: actions-rs/cargo@v1
with:
args: --release --target ${{ matrix.target }}
command: build
- name: Binaries | Prepare upload
run: |
# Include compile target in binary name
src="target/${{ matrix.target }}/release/${PROJ_NAME}"
dst="${GITHUB_WORKSPACE}/${PROJ_NAME}-${{ matrix.target }}"
if [[ "${RUNNER_OS}" == "Windows" ]]; then
src="${src}.exe"
dst="${dst}.exe"
fi
mv -v "${src}" "${dst}"
chmod -v +x "${dst}"
- name: Binaries | Upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJ_NAME }}-${{ matrix.target }}
path: ${{ env.PROJ_NAME }}-*
release:
name: Release
needs: binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Toolchain
uses: oxidecomputer/actions-rs_toolchain@oxide/master
# see https://github.com/actions-rs/toolchain/pull/209
# uses: actions-rs/toolchain@v1
with:
override: true
profile: minimal
target: ${{ matrix.target }}
- name: Operator | Cache
uses: Swatinem/rust-cache@v1
with:
key: release-operator-01
- name: Operator | Deduce
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_LABEL: release
RUST_LOG: info
run: |
# Run release operator
cargo run -p release-operator -- detect
- name: Binaries | Download
if: ${{ steps.release.outputs.release-detected == 'true' }}
uses: actions/download-artifact@v3
- name: Binaries | Checksums
if: ${{ steps.release.outputs.release-detected == 'true' }}
run: |
# Build binary checksums
for file in "${PROJ_NAME}"-*/"${PROJ_NAME}"-*; do
echo "Calculating checksum for: $(basename "${file}")"
openssl dgst -sha256 -r "${file}" \
| awk '{print $1}' > "${file}.sha256"
done
- name: Release | GitHub
if: ${{ steps.release.outputs.release-detected == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.release.outputs.tag-name }}
name: ${{ steps.release.outputs.tag-name }}
files: ${{ env.PROJ_NAME }}-*/${{ env.PROJ_NAME }}-*
- name: Release | Crates.io
if: ${{ steps.release.outputs.release-detected == 'true' }}
env:
RUST_LOG: info
run: |
# Publish to crates.io
cargo run -p release-operator -- publish \
--token ${{ secrets.CARGO_REGISTRY_TOKEN }} \
--crate crates/fj-math \
--crate crates/fj-proc \
--crate crates/fj \
--crate crates/fj-host \
--crate crates/fj-interop \
--crate crates/fj-kernel \
--crate crates/fj-export \
--crate crates/fj-operations \
--crate crates/fj-viewer \
--crate crates/fj-window \
--crate crates/fj-app