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