From cdbed21eac1450f2119a70e8902b5046b1a159dd Mon Sep 17 00:00:00 2001 From: Kyosuke Fujimoto Date: Sun, 28 Jul 2024 16:30:05 +0900 Subject: [PATCH] Add workflows --- .github/workflows/build.yml | 26 +++++++++++++++ .github/workflows/release.yml | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ce872ea --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: Build + +on: + push: + branches: + - '*' + pull_request: + branches: + - master + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Format + run: cargo fmt --all -- --check + - name: Build + run: cargo build --verbose + - name: Lint + run: cargo clippy --all-targets --all-features -- -D warnings + - name: Run tests + run: cargo test --verbose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8d627f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Release + +on: + push: + tags: + - 'v*' + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + strategy: + matrix: + targets: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + - target: x86_64-apple-darwin + os: macos-14 + - target: aarch64-apple-darwin + os: macos-14 + runs-on: ${{ matrix.targets.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup + run: rustup target add ${{ matrix.targets.target }} + - name: Build + run: cargo build --release --target ${{ matrix.targets.target }} + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> ${GITHUB_ENV} + - name: Archive + run: tar -czf serie-${{ env.RELEASE_VERSION }}-${{ matrix.targets.target }}.tar.gz -C target/${{ matrix.targets.target }}/release serie + - name: Checksum + run: shasum -a 256 serie-${{ env.RELEASE_VERSION }}-${{ matrix.targets.target }}.tar.gz + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: release-${{ matrix.targets.target }} + path: serie-${{ env.RELEASE_VERSION }}-${{ matrix.targets.target }}.tar.gz + if-no-files-found: error + release: + permissions: + contents: write + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + path: releases + pattern: release-* + merge-multiple: true + - name: Checksum + run: sha256sum releases/* > ./releases/checksum.txt + - name: Create Draft Release + uses: softprops/action-gh-release@v2.0.4 + with: + draft: true + generate_release_notes: true + make_latest: true + files: | + releases/*