From 09a39d42a347e1f4b1efa8b3bf4edb27ea748779 Mon Sep 17 00:00:00 2001 From: Yidi Date: Thu, 26 Sep 2024 21:09:51 -0400 Subject: [PATCH] feat(workflows): add GitHub Action to create release on new tag This workflow automates the release creation process whenever a new tag is pushed to the repository. It checks if a release for the tag already exists and creates one if it doesn't, enhancing the release management and streamlining the deployment process. --- .github/workflows/release-on-tag.yml | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/release-on-tag.yml diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml new file mode 100644 index 00000000..3d186544 --- /dev/null +++ b/.github/workflows/release-on-tag.yml @@ -0,0 +1,43 @@ +name: Create Release on Tag + +on: + push: + tags: + - '*' + +jobs: + create_release: + runs-on: ubuntu-latest + steps: + - name: Check if Release Exists + id: check_release + uses: actions/github-script@v7 + with: + script: | + try { + const release = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag: context.ref.replace('refs/tags/', ''), + }) + core.setOutput('release_exists', 'true') + } catch (error) { + if (error.status === 404) { + core.setOutput('release_exists', 'false') + } else { + throw error + } + } + + - name: Create Release + if: steps.check_release.outputs.release_exists == 'false' + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref_name }} + release_name: ${{ github.ref_name }} + body: | + Release ${{ github.ref_name }} of GORM. + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file