From a89aede6f9ab5083a8b70a6c949c89baec319cb2 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Wed, 6 Nov 2024 00:11:26 +0100 Subject: [PATCH] CI/CD to release nightly version to GH release --- .github/workflows/nightly.yml | 81 +++++++++++++++++++++++++++++++++++ Cargo.toml | 6 +-- 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..7e1a4ad --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,81 @@ +name: Nightly + +on: + workflow_dispatch: + schedule: + - cron: "0 23 * * *" + +permissions: + contents: write + +jobs: + build-and-upload: + name: Build and upload + runs-on: ${{ matrix.os }} + + strategy: + matrix: + # You can add more, for any target you'd like! + include: + - build: linux + os: ubuntu-latest + target: x86_64-unknown-linux-musl + + - build: macos + os: macos-latest + target: x86_64-apple-darwin + + - build: windows-gnu + os: windows-latest + target: x86_64-pc-windows-gnu + + steps: + - uses: actions/checkout@v4 + + - name: Get the release version from the tag + run: echo "VERSION=nightly-$(date +'%Y-%m-%d')-${{ github.sha }}" >> $GITHUB_ENV + shell: bash + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + # archived action, find an alternative + - name: Build + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --verbose --release --target ${{ matrix.target }} + + - name: Build archive + shell: bash + run: | + binary_names=("tatzwurm" "workwurm" "actionwurm") + dirname="${binary_names[0]}-${{ env.VERSION }}-${{ matrix.target }}" + mkdir "$dirname" + + # Move each binary to the directory + for binary_name in "${binary_names[@]}"; do + if [ "${{ matrix.os }}" = "windows-latest" ]; then + mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" + else + mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" + fi + done + + # Create archive based on OS + if [ "${{ matrix.os }}" = "windows-latest" ]; then + 7z a "$dirname.zip" "$dirname" + echo "ASSET=$dirname.zip" >> $GITHUB_ENV + else + tar -czf "$dirname.tar.gz" "$dirname" + echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV + fi + + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: | + ${{ env.ASSET }} diff --git a/Cargo.toml b/Cargo.toml index fdb437f..f4cb06b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,13 +21,13 @@ tokio-util = { version = "0.7.12", features = ["codec"] } uuid = { version = "1.10.0", features = ["fast-rng", "serde", "v4"] } [[bin]] -name = "coordinator" +name = "tatzelwurm" path = "src/main.rs" [[bin]] -name = "worker" +name = "workwurm" path = "src/bin/worker.rs" [[bin]] -name = "actioner" +name = "actionwurm" path = "src/bin/actioner.rs"