From f2c7b05f28a62137b8e4fdd3a4d0ef6d0d4dcfc4 Mon Sep 17 00:00:00 2001 From: Hendrik Maus Date: Thu, 24 Mar 2022 08:27:17 +0100 Subject: [PATCH] ci: create github release if the new release-operator detects that a release pull-request has been merged. that would be a pull-request tagged with the label 'release' and with a commit message that contains the semver version in the first line, e.g. 'release v0.5.1' --- .github/workflows/cd.yml | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0bcc0efa3..76f604133 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -73,3 +73,57 @@ jobs: with: name: ${{ env.PROJ_NAME }}-${{ matrix.target }}.exe path: ${{ env.PROJ_NAME }}-${{ matrix.target }}.exe + + release: + name: Release + needs: binaries + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Toolchain + uses: actions-rs/toolchain@v1 + with: + override: true + profile: minimal + toolchain: stable + + - name: Operator | Cache + uses: Swatinem/rust-cache@v1 + with: + key: release-operator-01 + working-directory: ./release-operator + + - name: Operator | Deduce + id: release + working-directory: ./release-operator + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_LABEL: release + RUST_LOG: info + run: | + # Run release operator + cargo run + + - name: Binaries | Download + if: ${{ steps.release.outputs.release-detected == 'true' }} + uses: actions/download-artifact@v3 + + - name: Binaries | Checksums + if: ${{ steps.release.outputs.release-detected == 'true' }} + run: | + # Build binary checksums + for file in "${PROJ_NAME}"-*/"${PROJ_NAME}"-*; do + echo "Calculating checksum for: $(basename "${file}")" + openssl dgst -sha256 -r "${file}" \ + | awk '{print $1}' > "${file}.sha256" + done + + - name: Create GitHub Release + if: ${{ steps.release.outputs.release-detected == 'true' }} + uses: softprops/action-gh-release@v0.1.14 + with: + tag_name: ${{ steps.release.outputs.tag-name }} + name: ${{ steps.release.outputs.tag-name }} + files: ${{ env.PROJ_NAME }}-*/${{ env.PROJ_NAME }}-*