Skip to content

Commit a9d51e0

Browse files
authored
Merge pull request #15 from TravisWheelerLab/dev
nail v0.4.0 | libnail v0.4.0
2 parents 38bff94 + 907daf2 commit a9d51e0

37 files changed

+4655
-3426
lines changed

.github/workflows/release.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
name: tag
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
REPO: "traviswheelerlab/nail"
10+
BIN: "nail"
11+
LIB: "libnail"
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
check-versions:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
BIN_VERSION: ${{ steps.versions.outputs.BIN_VERSION }}
21+
LIB_VERSION: ${{ steps.versions.outputs.LIB_VERSION }}
22+
BIN_VERSION_CHANGED: ${{ steps.versions.outputs.BIN_VERSION_CHANGED }}
23+
LIB_VERSION_CHANGED: ${{ steps.versions.outputs.LIB_VERSION_CHANGED }}
24+
steps:
25+
- name: checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
# fetch enough history to access the previous commit
29+
fetch-depth: 2
30+
31+
- name: set up git
32+
run: |
33+
git config --global user.name 'github-actions[bot]'
34+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
35+
36+
- name: check versions
37+
id: versions
38+
run: |
39+
BIN_VERSION=$(grep '^version' rb/Cargo.toml | head -n 1 | awk '{print $3}' | tr -d '"')
40+
LIB_VERSION=$(grep '^version' rl/Cargo.toml | head -n 1 | awk '{print $3}' | tr -d '"')
41+
42+
echo "BIN_VERSION=${BIN_VERSION}" >> $GITHUB_OUTPUT
43+
echo "LIB_VERSION=${LIB_VERSION}" >> $GITHUB_OUTPUT
44+
45+
PREV_BIN_VERSION=$(git show origin/main^:rb/Cargo.toml | grep '^version' | head -n 1 | awk '{print $3}' | tr -d '"')
46+
PREV_LIB_VERSION=$(git show origin/main^:rl/Cargo.toml | grep '^version' | head -n 1 | awk '{print $3}' | tr -d '"')
47+
48+
if [[ "${PREV_BIN_VERSION}" != "${BIN_VERSION}" ]]; then
49+
echo "BIN_VERSION_CHANGED=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "BIN_VERSION_CHANGED=false" >> $GITHUB_OUTPUT
52+
fi
53+
54+
if [[ "${PREV_LIB_VERSION}" != "${LIB_VERSION}" ]]; then
55+
echo "LIB_VERSION_CHANGED=true" >> $GITHUB_OUTPUT
56+
else
57+
echo "LIB_VERSION_CHANGED=false" >> $GITHUB_OUTPUT
58+
fi
59+
60+
tag-bin:
61+
needs: check-versions
62+
if: needs.check-versions.outputs.BIN_VERSION_CHANGED == 'true'
63+
runs-on: ubuntu-latest
64+
65+
env:
66+
BIN_VERSION: ${{ needs.check-versions.outputs.BIN_VERSION }}
67+
LIB_VERSION: ${{ needs.check-versions.outputs.LIB_VERSION }}
68+
69+
steps:
70+
- name: checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: set up git
74+
run: |
75+
git config --global user.name 'github-actions[bot]'
76+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
77+
78+
- name: tag bin
79+
run: |
80+
git tag -a "${BIN}-v${BIN_VERSION}" -m "${BIN} v${BIN_VERSION} | ${LIB} v${LIB_VERSION}"
81+
git push origin "${BIN}-v${BIN_VERSION}"
82+
83+
tag-lib:
84+
needs: check-versions
85+
if: needs.check-versions.outputs.LIB_VERSION_CHANGED == 'true'
86+
runs-on: ubuntu-latest
87+
88+
env:
89+
BIN_VERSION: ${{ needs.check-versions.outputs.BIN_VERSION }}
90+
LIB_VERSION: ${{ needs.check-versions.outputs.LIB_VERSION }}
91+
92+
steps:
93+
- name: checkout code
94+
uses: actions/checkout@v4
95+
96+
- name: set up git
97+
run: |
98+
git config --global user.name 'github-actions[bot]'
99+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
100+
101+
- name: tag lib
102+
run: |
103+
git tag -a "${LIB}-v${LIB_VERSION}" -m "${BIN} v${BIN_VERSION} | ${LIB} v${LIB_VERSION}"
104+
git push origin "${LIB}-v${LIB_VERSION}"
105+
106+
build:
107+
needs: tag-bin
108+
strategy:
109+
matrix:
110+
os: [ubuntu-latest, windows-latest, macos-13]
111+
arch: [x86_64, aarch64]
112+
exclude:
113+
- os: windows-latest
114+
# cross-compiling for ARM on Windows
115+
# is not supported by Rust
116+
arch: aarch64
117+
runs-on: ${{ matrix.os }}
118+
env:
119+
TARGET: ${{ matrix.os == 'ubuntu-latest' && (
120+
matrix.arch == 'x86_64' && 'x86_64-unknown-linux-gnu' ||
121+
matrix.arch == 'aarch64' && 'aarch64-unknown-linux-gnu'
122+
) || matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' ||
123+
matrix.os == 'macos-13' && (
124+
matrix.arch == 'x86_64' && 'x86_64-apple-darwin' ||
125+
matrix.arch == 'aarch64' && 'aarch64-apple-darwin'
126+
) }}
127+
steps:
128+
- uses: actions/checkout@v4
129+
130+
- uses: actions-rs/toolchain@v1
131+
with:
132+
toolchain: stable
133+
override: true
134+
135+
- name: install rust target
136+
run: rustup target add ${{ env.TARGET }}
137+
138+
- name: install aarch64 toolchain (Linux ARM only)
139+
if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64'
140+
run: |
141+
sudo apt-get update
142+
sudo apt-get install -y gcc-aarch64-linux-gnu
143+
# tell cargo to actually use the ARM linker
144+
mkdir -p .cargo
145+
echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml
146+
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
147+
148+
- name: build binary
149+
run: cargo build --release --target ${{ env.TARGET }}
150+
151+
- name: upload artifact
152+
uses: actions/upload-artifact@v4
153+
with:
154+
name: ${{ env.BIN }}-${{ env.TARGET }}
155+
path: target/${{ env.TARGET }}/release/${{ env.BIN }}${{ matrix.os == 'windows-latest' && '.exe' || '' }}
156+
157+
build-macos-universal:
158+
runs-on: macos-latest
159+
needs: build
160+
steps:
161+
- uses: actions/download-artifact@v4
162+
with:
163+
name: ${{ env.BIN }}-x86_64-apple-darwin
164+
path: bin/x86_64
165+
166+
- uses: actions/download-artifact@v4
167+
with:
168+
name: ${{ env.BIN }}-aarch64-apple-darwin
169+
path: bin/aarch64
170+
171+
- name: create universal binary
172+
run: |
173+
lipo -create -output ${{ env.BIN }} \
174+
bin/x86_64/${{ env.BIN }} \
175+
bin/aarch64/${{ env.BIN }}
176+
177+
- name: upload universal binary
178+
uses: actions/upload-artifact@v4
179+
with:
180+
name: ${{ env.BIN }}-macos-universal
181+
path: ${{ env.BIN }}
182+
183+
release:
184+
needs: [check-versions, build, build-macos-universal]
185+
runs-on: ubuntu-latest
186+
env:
187+
BIN_VERSION: ${{ needs.check-versions.outputs.BIN_VERSION }}
188+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189+
steps:
190+
- name: download build artifacts
191+
uses: actions/download-artifact@v4
192+
with:
193+
pattern: ${{ env.BIN }}*
194+
path: ./artifacts
195+
196+
- name: make binaries executable
197+
run: |
198+
for b in ./artifacts/*/${{ env.BIN}}; do
199+
echo "making $b executable"
200+
[ -f "$b" ] && chmod +x "$b"
201+
done
202+
203+
- name: zip artifacts
204+
run: |
205+
echo "(pre-zip) listing files in ./artifacts:"
206+
ls -l ./artifacts/*
207+
cd artifacts
208+
209+
for d in *; do
210+
if [[ "$d" == *windows* ]]; then
211+
zip -r "$d.zip" "$d" && rm -rf "$d"
212+
else
213+
tar czf "$d.tar.gz" "$d" && rm -rf "$d"
214+
fi
215+
done
216+
217+
echo "(post-zip) listing files in ./artifacts:"
218+
ls -l *
219+
220+
- name: upload release assets
221+
uses: softprops/action-gh-release@v2
222+
with:
223+
files: ./artifacts/${{ env.BIN }}*
224+
tag_name: ${{ env.BIN }}-v${{ needs.check-versions.outputs.BIN_VERSION }}
225+
name: ${{ env.BIN }} ${{ needs.check-versions.outputs.BIN_VERSION }}
226+
prerelease: false
227+
draft: false
228+
token: ${{ secrets.GITHUB_TOKEN }}
229+
230+
create-asset-table:
231+
name: create asset table
232+
runs-on: ubuntu-latest
233+
needs: [release, check-versions]
234+
steps:
235+
- uses: actions/checkout@v3
236+
- name: Set up Python
237+
uses: actions/setup-python@v4
238+
with:
239+
python-version: '3.x' # Specify the version of Python to use
240+
241+
- name: install python
242+
run: python -m pip install --upgrade pip && pip install requests
243+
244+
- name: update release table
245+
working-directory: ${{ github.workspace }}/${{ env.PROJECT_PATH }} # set working directory
246+
run: |
247+
python .github/workflows/update_release_table.py ${{ env.REPO }} ${{ env.BIN }}-v${{ needs.check-versions.outputs.BIN_VERSION }}
248+
env:
249+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)