From 825ce6e737597c148a9e7ba10bcbc1de4b26313c Mon Sep 17 00:00:00 2001 From: Evan Luo Date: Sun, 1 Dec 2024 20:44:05 -0500 Subject: [PATCH 1/3] ci: update GitHub token in release workflow - Replace personal access token with GITHUB_TOKEN for create-pull-request action - Enhance security by using built-in GitHub token for authentication --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 396d56f4..62f174e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,7 +81,7 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: - token: ${{ secrets.PAT }} + token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: bump version to ${{ env.new_version }}" branch: "release/v${{ env.new_version }}" base: main From 993341e08b94b04e053922e887fa08e9cdc2b0e8 Mon Sep 17 00:00:00 2001 From: Evan Luo Date: Sun, 1 Dec 2024 20:46:01 -0500 Subject: [PATCH 2/3] ci: update version handling in release workflow - Remove 'v' prefix from new version for consistency - Improve version extraction and environment variable setting - Ensure clean version number is used in subsequent steps --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62f174e1..e371c07e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,8 +55,9 @@ jobs: run: | CURRENT_VERSION=$(node -p "require('./package.json').version") NEW_VERSION=$(npm version ${{ github.event.inputs.release-type }} --no-git-tag-version) + NEW_VERSION_CLEAN=${NEW_VERSION#v} echo "current_version=$CURRENT_VERSION" >> $GITHUB_ENV - echo "new_version=$NEW_VERSION" >> $GITHUB_ENV + echo "new_version=$NEW_VERSION_CLEAN" >> $GITHUB_ENV - name: Create or Checkout Release Branch run: | From 31f51e98269504449425bd902946a6153247dc4b Mon Sep 17 00:00:00 2001 From: Evan Luo Date: Sun, 1 Dec 2024 20:49:24 -0500 Subject: [PATCH 3/3] ci: update release workflow for improved automation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Modify checkout action to use dev branch • Remove creation of separate release branch • Update PR creation to use dev as source branch • Set PR to draft status • Add condition for GitHub release creation • Simplify overall release process --- .github/workflows/release.yml | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e371c07e..783c7a22 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,9 +21,10 @@ jobs: release: runs-on: ubuntu-latest steps: - - name: Checkout Repository + - name: Checkout dev Branch uses: actions/checkout@v4 with: + ref: dev fetch-depth: 0 - name: Import GPG Key @@ -59,42 +60,33 @@ jobs: echo "current_version=$CURRENT_VERSION" >> $GITHUB_ENV echo "new_version=$NEW_VERSION_CLEAN" >> $GITHUB_ENV - - name: Create or Checkout Release Branch - run: | - BRANCH="release/v${{ env.new_version }}" - if git show-ref --quiet refs/heads/$BRANCH; then - git checkout $BRANCH - else - git checkout -b $BRANCH - fi - - name: Update Dependencies and Version run: | npm install git add package.json package-lock.json git commit -m "chore: bump version to ${{ env.new_version }}" || echo "No changes to commit" - - name: Push Changes + - name: Push Changes to dev run: | - BRANCH="release/v${{ env.new_version }}" - git push origin $BRANCH + git push origin dev - - name: Create Pull Request + - name: Create Pull Request to main uses: peter-evans/create-pull-request@v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: bump version to ${{ env.new_version }}" - branch: "release/v${{ env.new_version }}" base: main + branch: dev title: "Release v${{ env.new_version }}" body: "Automated release PR for version ${{ env.new_version }}" delete-branch: false - draft: false + draft: true labels: 'release, automated' reviewers: 'EvanNotFound' assignees: 'EvanNotFound' - name: Create GitHub Release (Draft) + if: github.ref == 'refs/heads/main' && github.event_name == 'push' uses: ncipollo/release-action@v1 with: tag: "v${{ env.new_version }}"