Skip to content

Commit 8957e7d

Browse files
committed
WIP: CLI Artifacts fix
1 parent 7232f59 commit 8957e7d

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/artifacts.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: artifacts
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build-cli-artifacts:
8+
name: build-artifacts
9+
runs-on: ${{ matrix.os }}
10+
env:
11+
TARGET_FLAGS:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: ubuntu-latest
17+
target: aarch64-unknown-linux-gnu
18+
- os: ubuntu-latest
19+
target: aarch64-unknown-linux-musl
20+
- os: ubuntu-latest
21+
target: x86_64-unknown-linux-gnu
22+
- os: ubuntu-latest
23+
target: x86_64-unknown-linux-musl
24+
- os: macos-latest
25+
target: x86_64-apple-darwin
26+
- os: macos-latest
27+
target: x86_64-apple-darwin
28+
- os: macos-latest
29+
target: aarch64-apple-darwin
30+
- os: windows-latest
31+
target: aarch64-pc-windows-msvc
32+
- os: windows-latest
33+
target: x86_64-pc-windows-gnu
34+
- os: windows-latest
35+
target: x86_64-pc-windows-gnu
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v5
40+
41+
- name: Set up Rust
42+
run: rustup toolchain add --profile minimal --target ${{ matrix.target }} stable
43+
44+
- name: Install cross
45+
run: cargo install cross
46+
47+
- name: Set target variables
48+
shell: bash
49+
run: |
50+
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
51+
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
52+
53+
- name: Show command used for Cargo
54+
shell: bash
55+
run: |
56+
echo "cargo command is: ${{ env.CARGO }}"
57+
echo "target flag is: ${{ env.TARGET_FLAGS }}"
58+
echo "target dir is: ${{ env.TARGET_DIR }}"
59+
60+
- name: Build release binary
61+
shell: bash
62+
# cd ensures we only pull in CLI dependencies
63+
run: |
64+
cd rust/dbn-cli
65+
cross build --release --bin dbn ${{ env.TARGET_FLAGS }}
66+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
67+
bin="target/${{ matrix.target }}/release/dbn.exe"
68+
else
69+
bin="target/${{ matrix.target }}/release/dbn"
70+
fi
71+
cd -
72+
stat $bin
73+
echo "BIN=$bin" >> $GITHUB_ENV
74+
75+
- name: Determine archive name
76+
shell: bash
77+
run: |
78+
version="$(scripts/get_version.sh)"
79+
echo "ARCHIVE=dbn-$version-${{ matrix.target }}" >> $GITHUB_ENV
80+
echo "VERSION=$version" >> $GITHUB_ENV
81+
82+
- name: Creating directory for archive
83+
shell: bash
84+
run: |
85+
mkdir -p "$ARCHIVE"/{complete,doc}
86+
cp "$BIN" "$ARCHIVE"/
87+
cp {rust/dbn-cli/README.md,LICENSE} "$ARCHIVE"/
88+
cp CHANGELOG.md "$ARCHIVE"/doc/
89+
90+
- name: Build archive (Windows)
91+
shell: bash
92+
if: matrix.os == 'windows-latest'
93+
run: |
94+
7z a "$ARCHIVE.zip" "$ARCHIVE"
95+
certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"
96+
echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV
97+
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV
98+
99+
- name: Build archive (Unix)
100+
shell: bash
101+
if: matrix.os != 'windows-latest'
102+
run: |
103+
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
104+
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
105+
echo "ASSET=$ARCHIVE.tar.gz" >> $GITHUB_ENV
106+
echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV
107+
108+
- name: Upload release archive
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
shell: bash
112+
run: |
113+
gh release upload v${{ env.VERSION }} ${{ env.ASSET }} ${{ env.ASSET_SUM }}

0 commit comments

Comments
 (0)