From a572acb1d9d76659eafbba2817e4882817ae72ef Mon Sep 17 00:00:00 2001 From: Ricky Lopez Date: Tue, 14 May 2024 17:19:59 -0700 Subject: [PATCH] Fix release naming --- .github/actions/archive/action.yml | 6 +++--- .github/workflows/release.yml | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/actions/archive/action.yml b/.github/actions/archive/action.yml index 4ca0d06..801c0fa 100644 --- a/.github/actions/archive/action.yml +++ b/.github/actions/archive/action.yml @@ -24,9 +24,9 @@ runs: [[ -z $sha_short ]] && sha_short="unknown" echo "sha_short=$sha_short" >> "$GITHUB_OUTPUT" - echo "github_ref: ${{ github.ref }}" - if [[ ${{ github.ref }} =~ refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then - export archive_name="conUDS_${{ github.ref_name }}_${{ inputs.target }}.zip" + if [[ "$GIT_TAG" != "none" ]]; then + printf "\nThis commit has a tag, using that in the archive name\n" + export archive_name="conUDS_${GIT_TAG}_${{ inputs.target }}.zip" else export archive_name="conUDS_${sha_short}_${{ inputs.target }}.zip" fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf0f5a2..afb9ddb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,10 +2,11 @@ on: push: branches: - main + name: Auto Release jobs: build_and_release: - name: Build + name: Build and Release runs-on: ubuntu-latest strategy: fail-fast: false @@ -18,13 +19,19 @@ jobs: - uses: ./.github/actions/build-rust with: target: ${{ matrix.target }} + - name: Get Tag + shell: bash + run: | + export GIT_TAG=$(git describe --tags --abbrev=0) + [[ -z "$GIT_TAG" ]] && GIT_TAG=none + echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV - name: Create Artifact Archive id: create-archive uses: ./.github/actions/archive with: target: ${{ matrix.target }} # make pre-release for regular pushes - - if: ${{ ! startsWith(github.ref, 'refs/tags/v') }} + - if: ${{ env.GIT_TAG == 'none' }} uses: marvinpinto/action-automatic-releases@v1.2.1 with: repo_token: "${{ secrets.GITHUB_TOKEN }}" @@ -35,7 +42,7 @@ jobs: ${{ steps.create-archive.outputs.archive_name }} CHECKSUM # make a real release if there's a tag - - if: ${{ startsWith(github.ref, 'refs/tags/v') }} + - if: ${{ env.GIT_TAG != 'none' }} uses: marvinpinto/action-automatic-releases@v1.2.1 with: repo_token: "${{ secrets.GITHUB_TOKEN }}"