From 7917e5221963d472c17a69f77c2d6c9d692188ce Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Wed, 21 Feb 2024 09:47:04 -0600 Subject: [PATCH] Make the auto-release via tag depend on a successful build (#64) Signed-off-by: Dean Roehrich --- .github/workflows/main.yaml | 34 +++++++++++++++++++------------ .github/workflows/verify_tag.yaml | 28 ------------------------- 2 files changed, 21 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/verify_tag.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e7cd05a..1d9f5e4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,15 +1,6 @@ name: Docker build and push -on: - push: - branches: - - '*' - tags: - - 'v*' - pull_request: - branches: - - 'master' - - 'releases/v*' +on: [push] env: # TEST_TARGET: Name of the testing target in the Dockerfile @@ -19,9 +10,6 @@ env: # The docker test current fails on this project DO_TEST: false - # DO_PUSH - true to push to the HPE_DEPLOY_REPO, false to not push - DO_PUSH: true - jobs: build: runs-on: ubuntu-latest @@ -103,3 +91,23 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} + create_release: + needs: build + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-tags: true + fetch-depth: 0 + - name: Repair tag + run: git fetch -f origin ${{ github.ref }}:${{ github.ref }} + - name: Verify that the tag is annotated + run: if test x$(git for-each-ref ${{ github.ref }} | awk '{print $2}') = xtag; then /bin/true; else echo "\"${{ github.ref }}\" does not look like an annotated tag!"; /bin/false; fi + - name: Release + uses: softprops/action-gh-release@v1 + with: + #prerelease: true + generate_release_notes: true + diff --git a/.github/workflows/verify_tag.yaml b/.github/workflows/verify_tag.yaml deleted file mode 100644 index 2a75d91..0000000 --- a/.github/workflows/verify_tag.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Pushing a tag triggers this workflow, which verifies that it is an -# annotated tag. -name: Verify tag - -on: - push: - tags: - - "v*" - -jobs: - verify_tag: - runs-on: ubuntu-latest - steps: - - name: "Verify context" - run: | - echo "ref is ${{ github.ref }}" - echo "ref_type is ${{ github.ref_type }}" - - - uses: actions/checkout@v3 - # actions/checkout@v3 breaks annotated tags by converting them into - # lightweight tags, so we need to force fetch the tag again - # See: https://github.com/actions/checkout/issues/290 - - name: "Repair tag" - run: git fetch -f origin ${{ github.ref }}:${{ github.ref }} - - name: "Verify tag is annotated" - run: if test x$(git for-each-ref ${{ github.ref }} | awk '{print $2}') = xtag; then /bin/true; else echo "\"${{ github.ref }}\" does not look like an annotated tag!"; /bin/false; fi - - name: "Echo release tag" - run: echo "TAG=${{ github.repository }}:${{ github.ref }}"