Skip to content

Commit

Permalink
ci: ubuntu_setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
slowsage committed Mar 22, 2024
1 parent 1dbd933 commit d65df93
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
20 changes: 20 additions & 0 deletions .github/scripts/ubuntu_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# sudo needed for github runner, not available by default for cross images
if command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
SUDO=""
fi

# Needed for cross-compilation
if [ -n "$CROSS_DEB_ARCH" ]; then
$SUDO dpkg --add-architecture "$CROSS_DEB_ARCH"
fi

# CROSS_DEB_ARCH is empty for native builds
$SUDO apt-get update && $SUDO apt-get install --assume-yes \
libssl-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libgtk-3-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libgtk-layer-shell-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libpulse-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH}
17 changes: 12 additions & 5 deletions .github/workflows/binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ jobs:
- uses: taiki-e/install-action@v2
with:
tool: cross
- run: cargo add openssl --features vendored
- run: cross build --locked --release --target=${{ matrix.platform.target }}
- run: echo "BINARY_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select( .kind | map(. == "bin") | any ) | .name')" >> $GITHUB_ENV

- if: ${{ matrix.platform.zipext == '.tar.gz' }}
- name: Add OpenSSL crate (vendored)
run: cargo add openssl --features vendored

- name: Cross Build Release
run: cross build --locked --release --target=${{ matrix.platform.target }}

- name: Get name of Binary from metadata
run: echo "BINARY_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].targets[] | select( .kind | map(. == "bin") | any ) | .name')" >> $GITHUB_ENV

- name: Compress the built binary
if: ${{ matrix.platform.zipext == '.tar.gz' }}
run: tar -zcvf ${{env.BINARY_NAME}}-${{github.ref_name}}-${{matrix.platform.target}}.tar.gz -C target/${{matrix.platform.target}}/release ${{env.BINARY_NAME}}

- name: Release
- name: Upload to release
run: gh release upload ${GITHUB_REF#refs/*/} ${{env.BINARY_NAME}}-${{github.ref_name}}-${{matrix.platform.target}}${{matrix.platform.zipext}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 4 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ jobs:
name: Cache dependencies

- name: Install build deps
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev libgtk-layer-shell-dev libpulse-dev
run: ./.github/scripts/ubuntu_setup.sh

- name: Clippy
run: cargo clippy --no-default-features --features config+json
Expand All @@ -53,9 +51,7 @@ jobs:
name: Cache dependencies

- name: Install build deps
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev libgtk-layer-shell-dev libpulse-dev
run: ./.github/scripts/ubuntu_setup.sh

- name: Clippy
run: cargo clippy --all-targets --all-features
Expand All @@ -72,14 +68,12 @@ jobs:
name: Cache dependencies

- name: Install build deps
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev libgtk-layer-shell-dev libpulse-dev
run: ./.github/scripts/ubuntu_setup.sh

- name: Build
run: cargo build --verbose

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
command: test
6 changes: 2 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ jobs:
override: true

- name: Install build deps
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev libgtk-layer-shell-dev libpulse-dev
run: ./.github/scripts/ubuntu_setup.sh

- name: Update CHANGELOG
id: changelog
Expand Down Expand Up @@ -48,4 +46,4 @@ jobs:

- uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
5 changes: 1 addition & 4 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[build]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH libgtk-3-dev:$CROSS_DEB_ARCH libgtk-layer-shell-dev:$CROSS_DEB_ARCH libpulse-dev:$CROSS_DEB_ARCH",
]
pre-build = "./.github/scripts/ubuntu_setup.sh"
[target.aarch64-unknown-linux-gnu]
image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"

Expand Down

0 comments on commit d65df93

Please sign in to comment.