diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b458d6..13e02df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,10 @@ name: Release on: release: - types: [ created ] + types: [created] + push: + branches: [master] + pull_request: env: CARGO_TERM_COLOR: always @@ -27,18 +30,35 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Get tag - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Get tag or commit + run: | + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + else + SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7) + echo "RELEASE_VERSION=${SHORT_SHA}" >> $GITHUB_ENV + fi shell: bash + - name: Build run: | cargo build --release + - name: Compress run: | cp -f target/release/$REPO${{ matrix.bin_extension }} . tar -czf release.tar.gz $REPO${{ matrix.bin_extension }} shell: bash + + - name: Archive build artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ env.REPO }}-${{ env.RELEASE_VERSION }}-${{ matrix.os_name }} + path: release.tar.gz + - name: Upload binaries to release + if: github.event_name == 'release' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }}