From bbbb947b7799b5034d77b3fa32539b1a9a69de95 Mon Sep 17 00:00:00 2001 From: stefanorosanelli Date: Tue, 6 Sep 2022 12:22:51 +0200 Subject: [PATCH 1/2] feat: use github script --- .github/workflows/release.yml | 44 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 889e9db..9f5c29e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,29 +81,33 @@ jobs: run: | echo Can't create a release on branch ${{ steps.branch.outputs.BRANCH }} exit 1 - - name: Create major release + + - name: Setup major tag if: contains(github.event.pull_request.labels.*.name, 'release:major') - uses: ncipollo/release-action@v1 - with: - name: 'Release ${{ steps.versions.outputs.NEW_MAJOR }}' - tag: 'v${{ steps.versions.outputs.NEW_MAJOR }}' - commit: ${{ steps.branch.outputs.BRANCH }} - generateReleaseNotes: true + run: "echo \"RELEASE_TAG=${ steps.versions.outputs.NEW_MAJOR }\" >> $GITHUB_ENV" - - name: Create minor release + - name: Setup minor tag if: contains(github.event.pull_request.labels.*.name, 'release:minor') - uses: ncipollo/release-action@v1 - with: - name: 'Release ${{ steps.versions.outputs.NEW_MINOR }}' - tag: 'v${{ steps.versions.outputs.NEW_MINOR }}' - commit: ${{ steps.branch.outputs.BRANCH }} - generateReleaseNotes: true + run: "echo \"RELEASE_TAG=${ steps.versions.outputs.NEW_MINOR }\" >> $GITHUB_ENV" - - name: Create patch release + - name: Setup patch tag if: contains(github.event.pull_request.labels.*.name, 'release:patch') - uses: ncipollo/release-action@v1 + run: "echo \"RELEASE_TAG=${ steps.versions.outputs.NEW_PATCH }\" >> $GITHUB_ENV" + + - name: "Create release" + uses: "actions/github-script@v6" with: - name: 'Release ${{ steps.versions.outputs.NEW_PATCH }}' - tag: 'v${{ steps.versions.outputs.NEW_PATCH }}' - commit: ${{ steps.branch.outputs.BRANCH }} - generateReleaseNotes: true \ No newline at end of file + script: | + try { + await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + } catch (error) { + core.setFailed(error.message); + } \ No newline at end of file From 03d66d87219468dfeaf19bda22c8462edb54ec74 Mon Sep 17 00:00:00 2001 From: stefanorosanelli Date: Tue, 6 Sep 2022 12:32:13 +0200 Subject: [PATCH 2/2] chore: fix --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f5c29e..4a6b51c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,15 +84,15 @@ jobs: - name: Setup major tag if: contains(github.event.pull_request.labels.*.name, 'release:major') - run: "echo \"RELEASE_TAG=${ steps.versions.outputs.NEW_MAJOR }\" >> $GITHUB_ENV" + run: "echo \"RELEASE_TAG=${{ steps.versions.outputs.NEW_MAJOR }}\" >> $GITHUB_ENV" - name: Setup minor tag if: contains(github.event.pull_request.labels.*.name, 'release:minor') - run: "echo \"RELEASE_TAG=${ steps.versions.outputs.NEW_MINOR }\" >> $GITHUB_ENV" + run: "echo \"RELEASE_TAG=${{ steps.versions.outputs.NEW_MINOR }}\" >> $GITHUB_ENV" - name: Setup patch tag if: contains(github.event.pull_request.labels.*.name, 'release:patch') - run: "echo \"RELEASE_TAG=${ steps.versions.outputs.NEW_PATCH }\" >> $GITHUB_ENV" + run: "echo \"RELEASE_TAG=${{ steps.versions.outputs.NEW_PATCH }}\" >> $GITHUB_ENV" - name: "Create release" uses: "actions/github-script@v6"