diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..545e852 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,78 @@ +name: Rust CI and release + +on: + push: + branches: + - '**' + tags: + - '*' + pull_request: + branches: + - '**' + +jobs: + build: + runs-on: ubuntu-22.04 + + env: + RP2040_FIRMWARE_VERSION: 0.2.14 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.77.1 + override: true + + - name: Display Rust and Cargo version + run: | + rustc --version + cargo --version + + - name: Install dependencies + run: | + sudo apt-get update && sudo apt-get install -y \ + gcc-aarch64-linux-gnu \ + libc6-arm64-cross \ + libc6-dev-arm64-cross \ + binutils-aarch64-linux-gnu + + - name: Add target for cross-compilation + run: rustup target add aarch64-unknown-linux-musl + + - name: Configure Cargo for cross-compilation + run: | + mkdir -p ~/.cargo + echo '[target.aarch64-unknown-linux-musl]' > ~/.cargo/config + echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config + + - name: Update version in Cargo.toml if tag exists + if: startsWith(github.ref, 'refs/tags/') + run: | + TAG=${GITHUB_REF#refs/tags/} + sed -i "s/version = \"0.0.0-snapshot\"/version = \"${TAG#v}\"/g" Cargo.toml + + - name: Install cargo-deb + run: cargo install cargo-deb --version 2.3.0 + + - name: Download firmware files + run: | + mkdir -p _releases + wget -O _releases/tc2-firmware.sha256 https://github.com/TheCacophonyProject/tc2-firmware/releases/download/v${RP2040_FIRMWARE_VERSION}/tc2-firmware.sha256 + wget -O _releases/tc2-firmware https://github.com/TheCacophonyProject/tc2-firmware/releases/download/v${RP2040_FIRMWARE_VERSION}/tc2-firmware + + - name: Build the project + run: cargo build --release --target=aarch64-unknown-linux-musl + + - name: Create Debian package + run: cargo deb --target=aarch64-unknown-linux-musl --output tc2-agent_${GITHUB_REF#refs/tags/v}_arm64.deb + + - name: Upload release assets + if: startsWith(github.ref, 'refs/tags/') + uses: ncipollo/release-action@v1 + with: + artifacts: '*.deb' + allowUpdates: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ff869dc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ -language: rust -rust: - - stable - -os: linux -dist: focal - -addons: - apt: - packages: - - gcc-aarch64-linux-gnu - - libc6-arm64-cross - - libc6-dev-arm64-cross - - binutils-aarch64-linux-gnu - -env: - global: - - RP2040_FIRMWARE_VERSION=0.2.14 - -before_script: - - rustup target add aarch64-unknown-linux-musl - - | - echo "[target.aarch64-unknown-linux-musl]" > ~/.cargo/config - echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config - - -script: - - if [ -n "$TRAVIS_TAG" ]; then sed -i "s/version = \"0.0.0-snapshot\"/version = \"${TRAVIS_TAG#v}\"/g" Cargo.toml; fi - - cargo install cargo-deb --version 2.3.0 - - wget -O _releases/tc2-firmware.sha256 https://github.com/TheCacophonyProject/tc2-firmware/releases/download/v${RP2040_FIRMWARE_VERSION}/tc2-firmware.sha256 - - cat _releases/tc2-firmware.sha256 - - wget -O _releases/tc2-firmware https://github.com/TheCacophonyProject/tc2-firmware/releases/download/v${RP2040_FIRMWARE_VERSION}/tc2-firmware - - cargo build --release --target=aarch64-unknown-linux-musl - - cargo deb --target=aarch64-unknown-linux-musl --output tc2-agent_${TRAVIS_TAG#v}_arm64.deb - -deploy: - provider: releases - token: $GITHUB_TOKEN - file: - - "tc2-agent_${TRAVIS_TAG#v}_arm64.deb" - skip_cleanup: true - on: - tags: true