diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..f0d1a28 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + - name: Linux GUI dependencies + run: sudo apt-get update && sudo apt-get install -y libxkbcommon-dev libgtk-3-dev + - run: cargo fmt --check + - run: cargo clippy --all-targets --locked -- -D warnings + - run: cargo test --release --locked diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..c1f1d67 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,45 @@ +name: Release + +# v* tags build the Windows binary and attach it to a Gitea release. +# Manual runs (Actions tab -> Release -> Run workflow) build the same zip as a +# downloadable workflow artifact without creating a release. +on: + push: + tags: ["v*"] + workflow_dispatch: + +env: + TARGET: x86_64-pc-windows-gnu + # Statically link the C runtime so the .exe needs no mingw DLLs alongside it. + RUSTFLAGS: -C target-feature=+crt-static + +jobs: + windows: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-gnu + - name: Install mingw-w64 + run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 zip + - run: cargo build --release --locked --target "$TARGET" + - name: Package + run: | + if [ "$GITHUB_REF_TYPE" = "tag" ]; then version="$GITHUB_REF_NAME"; else version="$(git rev-parse --short HEAD)"; fi + name="logreadlite-${version}-windows-x86_64" + mkdir "$name" + cp "target/$TARGET/release/logreadlite.exe" README.md "$name/" + x86_64-w64-mingw32-strip "$name/logreadlite.exe" + zip -r "$name.zip" "$name" + echo "ZIP=$name.zip" >> "$GITHUB_ENV" + # Gitea's artifact backend is compatible with upload-artifact v3. + - uses: actions/upload-artifact@v3 + with: + name: ${{ env.ZIP }} + path: ${{ env.ZIP }} + - name: Create Gitea release + if: github.ref_type == 'tag' + uses: akkuman/gitea-release-action@v1 + with: + files: ${{ env.ZIP }}