Skip to content

Commit

Permalink
chore: clean-up and test builds for deb/rpm (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeeshan Lakhani authored Oct 11, 2023
1 parent edd2f21 commit 1574aea
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 16 deletions.
65 changes: 49 additions & 16 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: ⚃ Builds

# TODO: brew formula (Macs), cargo-wix (Windows Installs), cargo-aur (Arch)

on:
workflow_dispatch:
inputs:
Expand All @@ -11,6 +13,10 @@ on:
release:
types: [published]

# for debugging
# pull_request:
# branches: [ '**' ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -50,9 +56,6 @@ jobs:
id: toolchain
uses: dtolnay/rust-toolchain@stable

- name: Override rust-toolchain.toml
run: rustup override set ${{steps.toolchain.outputs.name}}

- name: Cache Project
uses: Swatinem/rust-cache@v2
with:
Expand All @@ -68,7 +71,20 @@ jobs:
run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >>"${GITHUB_ENV}"
if: endsWith(matrix.target, 'windows-msvc')

- name: Compile
if: github.event_name != 'release'
run: cargo build -p homestar-runtime --locked --release --target ${{ matrix.target }}

- name: Upload Release Artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/homestar*
if-no-files-found: error

- name: Publish Binary in Release
if: github.event_name == 'release' && github.event.action == 'published'
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: homestar
Expand All @@ -91,6 +107,16 @@ jobs:
- name: Install musl-tools
run: sudo apt update && sudo apt install -y musl-dev musl-tools

- name: Install Rust toolchain
id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ env.LINUX_TARGET }}

- name: Override rust-toolchain.toml
run: rustup override set ${{steps.toolchain.outputs.name}}

- name: Install cargo-deb
uses: taiki-e/cache-cargo-install-action@v1
with:
Expand All @@ -108,29 +134,27 @@ jobs:
shared-key: check-${{ env.LINUX_TARGET }}-ubuntu-latest

- name: Create .deb
run: cargo deb -p homestar-runtime --target ${{env.LINUX_TARGET}}
run: cargo deb -p homestar-runtime --target ${{ env.LINUX_TARGET }} --output homestar.deb

- name: Create .rpm
run: cargo generate-rpm
run: cargo generate-rpm -p homestar-runtime --target ${{ env.LINUX_TARGET }} --output homestar.rpm

- name: Publish Release Artifacts
- name: Upload Release Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
name: ${{ env.LINUX_TARGET }}
path: |
target/generate-rpm/
target/${{env.LINUX_TARGET}}/debian/
*.deb
*.rpm
if-no-files-found: error

- name: Publish Package in Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'release' && github.event.action == 'published'
with:
files: |
target/${{env.LINUX_TARGET}}/debian/*.deb
target/generate-rpm/*.rpm
# TODO: brew formula (Macs), cargo-wix (Windows Installs), cargo-aur (Arch)
*.deb
*.rpm
docker-build:
runs-on: ubuntu-latest
Expand All @@ -149,6 +173,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Cleanup
run: |
# Workaround to provide additional free space for testing.
# https://github.com/actions/virtual-environments/issues/2840
rm -rf /opt/hostedtoolcache
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf "$AGENT_TOOLSDIRECTORY"
sudo apt-get clean
sudo rm -rf /usr/share/dotnet
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand All @@ -161,8 +196,6 @@ jobs:

- name: Setup Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: "--debug"

- name: Metadata
id: meta
Expand Down
1 change: 1 addition & 0 deletions homestar-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ rustdoc-args = ["--cfg", "docsrs"]
maintainer = "James Walker <james@fission.codes>"
license-file = ["LICENSE", "0"]
extended-description-file = "README.md"
depends = ""
section = "network"
priority = "optional"
assets = [
Expand Down

0 comments on commit 1574aea

Please sign in to comment.