From c3542ba88a22e13086be71d7bcd93f447c92b838 Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Sat, 3 Jun 2023 14:12:46 -0400 Subject: [PATCH] Limit Release action to release event, add sums to artifacts --- .github/workflows/main-rust.yml | 47 +++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main-rust.yml b/.github/workflows/main-rust.yml index c7e98c8..d6486c8 100644 --- a/.github/workflows/main-rust.yml +++ b/.github/workflows/main-rust.yml @@ -31,44 +31,51 @@ jobs: with: toolchain: stable + # Building actions - name: Build run: cargo build --release - - name: Build MUSL - run: cargo build --release --target x86_64-unknown-linux-musl - - - name: Publish to crates.io - if: github.event_name == 'release' - run: cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} - - - uses: actions/upload-artifact@v3 - name: Upload a Build Artifact - with: - name: libreddit - path: target/release/libreddit - - - name: Versions - id: version - run: echo "VERSION=$(cargo metadata --format-version 1 --no-deps | jq .packages[0].version -r | sed 's/^/v/')" >> "$GITHUB_OUTPUT" - - name: Calculate SHA512 checksum run: sha512sum target/release/libreddit > libreddit.sha512 - name: Calculate SHA256 checksum run: sha256sum target/release/libreddit > libreddit.sha256 - + + - name: Build MUSL + run: cargo build --release --target x86_64-unknown-linux-musl + - name: Calculate MUSL SHA512 checksum run: sha512sum target/x86_64-unknown-linux-musl/release/libreddit > libreddit-musl.sha512 - name: Calculate MUSL SHA256 checksum run: sha256sum target/x86_64-unknown-linux-musl/release/libreddit > libreddit-musl.sha256 - + - name: Move MUSL binary run: mv target/x86_64-unknown-linux-musl/release/libreddit target/x86_64-unknown-linux-musl/release/libreddit-musl + - uses: actions/upload-artifact@v3 + name: Upload a Build Artifact + with: + name: libreddit + path: | + target/release/libreddit + target/x86_64-unknown-linux-musl/release/libreddit-musl + *.sha512 + *.sha256 + + - name: Versions + id: version + run: echo "VERSION=$(cargo metadata --format-version 1 --no-deps | jq .packages[0].version -r | sed 's/^/v/')" >> "$GITHUB_OUTPUT" + + # Publishing actions + + - name: Publish to crates.io + if: github.event_name == 'release' + run: cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} + - name: Release uses: softprops/action-gh-release@v1 - if: github.base_ref != 'master' + if: github.base_ref != 'master' && github.event_name == 'release' with: tag_name: ${{ steps.version.outputs.VERSION }} name: ${{ steps.version.outputs.VERSION }} - ${{ github.event.head_commit.message }}