-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update workflows to get version from Cargo.toml (#59)
* update workflows for test_build * update workflows for deploy * build_nohealthcheck: false * build_with_tmpfs: true * add binary build workflow * add sudo to apt- commands * add deps * multi-arch dependencies * multi-arch build troubleshooting * multi-arch build tshooting * multi-arch troubleshooting * tshoot * troubleshoot cross-build * add comment * tshoot * remove i386 * troubleshooting * troubleshoot * troubleshoot * troubleshoot * add build artifact upload * change name * use pre-built binary * move uses to step * troubleshooting * troubleshoot * add env * test artifacts * cache binaries * utilise action cache * disable ssh * fix needs * remove flake-8 linting * fix build * deal with multi-arch in a hacky way * ensure binaries are executable & clean up * exit 1 on fail * test release deploy * naming * troubleshoot release * troubleshoot release * change order of jobs * add tag * add tag commit * create tag * add checkout * troubleshoot release * final clean up * fix local builds * fix typo * add target back in * consolidate binaries * correct binary path * fix binary filenames * change name (pedantic)
- Loading branch information
Showing
5 changed files
with
344 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ on: | |
- "**.md" | ||
- "**.MD" | ||
- "**.yml" | ||
- "**.yaml" | ||
- "LICENSE" | ||
- ".gitattributes" | ||
- ".gitignore" | ||
|
@@ -38,14 +39,179 @@ jobs: | |
echo "Workflow dispatch reason: $INPUTS_REASON" | ||
echo "::notice title=${{ github.job }}: Workflow Dispatch Reason::${INPUTS_REASON}" | ||
binary_build: | ||
name: Build Binaries | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Install OS dependencies: armhf" | ||
uses: ryankurte/[email protected] | ||
with: | ||
arch: armhf | ||
packages: "libzmq3-dev:armhf" | ||
|
||
- name: "Install OS dependencies: arm64" | ||
uses: ryankurte/[email protected] | ||
with: | ||
arch: arm64 | ||
packages: "libzmq3-dev:arm64" | ||
|
||
# i386 currently does not work... | ||
# - name: "Install OS dependencies: i386" | ||
# uses: ryankurte/[email protected] | ||
# with: | ||
# arch: i386 | ||
# packages: "libzmq3-dev:i386" | ||
|
||
- name: "Install OS dependencies: arm64" | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y --no-install-recommends \ | ||
libzmq3-dev | ||
- name: "Install rust targets/toolchains for cross build" | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y --no-install-recommends \ | ||
g++-arm-linux-gnueabihf \ | ||
libc6-dev-armhf-cross \ | ||
g++-aarch64-linux-gnu \ | ||
libc6-dev-arm64-cross | ||
rustup target add armv7-unknown-linux-gnueabihf | ||
rustup toolchain install stable-armv7-unknown-linux-gnueabihf | ||
rustup target add aarch64-unknown-linux-gnu | ||
rustup toolchain install stable-aarch64-unknown-linux-gnu | ||
rustup target add x86_64-unknown-linux-gnu | ||
rustup toolchain install stable-x86_64-unknown-linux-gnu | ||
- name: Build armv7 | ||
run: | | ||
PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf RUSTFLAGS="-C linker=/usr/bin/arm-linux-gnueabihf-gcc" cargo build --release --target armv7-unknown-linux-gnueabihf | ||
- name: Build arm64 | ||
run: | | ||
PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu RUSTFLAGS="-C linker=/usr/bin/aarch64-linux-gnu-gcc" cargo build --release --target aarch64-unknown-linux-gnu | ||
- name: Build amd64 | ||
run: | | ||
cargo build --release | ||
- name: Consolidate binaries | ||
run: | | ||
mkdir -p ./bin | ||
cp -v ./target/release/acars_router ./bin/acars_router.amd64 | ||
cp -v ./target/armv7-unknown-linux-gnueabihf/release/acars_router ./bin/acars_router.armv7 | ||
cp -v ./target/aarch64-unknown-linux-gnu/release/acars_router ./bin/acars_router.arm64 | ||
- name: Upload artifact amd64 binary | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: acars_router.amd64 | ||
path: ./bin/acars_router.amd64 | ||
|
||
- name: Upload artifact armv7 binary | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: acars_router.armv7 | ||
path: ./bin/acars_router.armv7 | ||
|
||
- name: Upload artifact arm64 binary | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: acars_router.arm64 | ||
path: ./bin/acars_router.arm64 | ||
|
||
- name: Cache Cargo Build Output | ||
uses: actions/cache@v3 | ||
with: | ||
path: bin/ | ||
key: ${{ github.run_id }} | ||
|
||
# # Allows troubleshooting via SSH | ||
# - name: Setup upterm session | ||
# uses: lhotari/action-upterm@v1 | ||
# env: | ||
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# limit-access-to-users: mikenye | ||
|
||
release_binaries: | ||
name: Release Binaries | ||
needs: [binary_build] | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Cache cargo build output | ||
id: get_cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: bin/ | ||
key: ${{ github.run_id }} | ||
|
||
- name: Check cache | ||
if: steps.get_cache.outputs.cache-hit != 'true' | ||
run: | | ||
echo "::error title=${{ github.job }}: Could not get binaries from action cache" | ||
exit 1 | ||
- name: Prepare binary release tarballs | ||
if: steps.get_cache.outputs.cache-hit == 'true' | ||
run: | | ||
ORIGDIR=$(pwd) | ||
# Make release tarballs | ||
mkdir -vp ./release | ||
pushd ./bin | ||
tar cJvf "$ORIGDIR/release/acars_router.amd64.tar.xz" ./acars_router.amd64 | ||
tar cJvf "$ORIGDIR/release/acars_router.armv7.tar.xz" ./acars_router.armv7 | ||
tar cJvf "$ORIGDIR/release/acars_router.arm64.tar.xz" ./acars_router.arm64 | ||
popd | ||
- name: Get binary version from Cargo.toml | ||
if: steps.get_cache.outputs.cache-hit == 'true' | ||
id: release_version | ||
run: | | ||
# Get version from Cargo.toml | ||
RELEASE_VERSION=$(cat Cargo.toml | grep '\[package\]' -A9999 | grep -m 1 'version = ' | tr -d " " | tr -d '"' | tr -d "'" | cut -d = -f 2) | ||
echo "::set-output name=RELEASE_VERSION::$RELEASE_VERSION" | ||
- name: Create tag | ||
uses: rickstaa/action-create-tag@v1 | ||
with: | ||
tag: ${{ steps.release_version.outputs.RELEASE_VERSION }} | ||
|
||
- name: Create binary release | ||
if: steps.get_cache.outputs.cache-hit == 'true' | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: ./release/*.tar.xz | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
name: ${{ steps.release_version.outputs.RELEASE_VERSION }} | ||
tag: ${{ steps.release_version.outputs.RELEASE_VERSION }} | ||
|
||
deploy: | ||
name: Deploy | ||
needs: [binary_build] | ||
uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main | ||
with: | ||
push_enabled: true | ||
push_destinations: ghcr.io | ||
ghcr_repo_owner: ${{ github.repository_owner }} | ||
ghcr_repo: ${{ github.repository }} | ||
build_with_tmpfs: true | ||
get_version_method: cargo_toml_file_in_repo:file=/Cargo.toml | ||
build_nohealthcheck: false | ||
cache_enabled: true | ||
cache_path: bin/ | ||
cache_key: ${{ github.run_id }} | ||
secrets: | ||
ghcr_token: ${{ secrets.GITHUB_TOKEN }} |
Oops, something went wrong.