From 0dd828187c839ca2e2e73b4a827233085fecf905 Mon Sep 17 00:00:00 2001 From: Mehmet Bektas Date: Fri, 23 Feb 2024 21:17:59 -0800 Subject: [PATCH] release pull request workflow --- .github/workflows/prerelease.yml | 2 +- .github/workflows/releasepr.yml | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/releasepr.yml diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 575b302f..61666ae5 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: jobs: - build: + prerelease: runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/releasepr.yml b/.github/workflows/releasepr.yml new file mode 100644 index 00000000..37c919d6 --- /dev/null +++ b/.github/workflows/releasepr.yml @@ -0,0 +1,48 @@ +name: Create Release PR + +on: + workflow_dispatch: + +jobs: + createPR: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get package info + shell: bash + id: package-info + run: echo "version=$(python scripts/get_package_version.py)" >> $GITHUB_OUTPUT + + - name: 'Find pre-release with tag v${{ steps.package-info.outputs.version}}' + uses: actions/github-script@v7 + id: pre-release-exists + env: + APP_VERSION: ${{ steps.package-info.outputs.version}} + with: + script: | + const releases = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo + }) + const tagName = `v${process.env.APP_VERSION}` + const releaseWithTag = releases.data.find(release => release.tag_name === tagName && (release.draft || release.prerelease)) + return releaseWithTag ? 'true' : 'false' + result-encoding: string + + - name: Make changes to pull request + if: steps.pre-release-exists.outputs.result == 'true' + run: date +%s > auto-release-log.txt + + - name: Create Release pull request + if: steps.pre-release-exists.outputs.result == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.JLAB_APP_TOKEN }} + commit-message: Update auto-release logs + branch: release-v${{ steps.package-info.outputs.version}} + title: 'Release v${{ steps.package-info.outputs.version}}' + body: | + Release v${{ steps.package-info.outputs.version}} + draft: false