diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f09d0ab --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + name: Build ${{ matrix.archive }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + archive: steplock-Linux-x86_64 + - os: macos-latest + target: aarch64-apple-darwin + archive: steplock-Darwin-arm64 + - os: macos-13 + target: x86_64-apple-darwin + archive: steplock-Darwin-x86_64 + steps: + - uses: actions/checkout@v4 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + core/target + key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('core/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.target }}-cargo-release- + + - name: Build + run: cargo build --manifest-path core/Cargo.toml --release --target ${{ matrix.target }} + + - name: Package + run: | + cd core/target/${{ matrix.target }}/release + tar -czf "${{ matrix.archive }}.tar.gz" steplock + mv "${{ matrix.archive }}.tar.gz" ../../../../ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.archive }} + path: ${{ matrix.archive }}.tar.gz + + release: + name: Create GitHub Release + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Create release + run: | + gh release create "${{ github.ref_name }}" \ + --title "${{ github.ref_name }}" \ + --generate-notes \ + artifacts/*.tar.gz + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish: + name: Publish to crates.io + needs: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Publish crate + run: cargo publish --manifest-path core/Cargo.toml + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}