diff --git a/.github/workflows/update-version-file-on-release.yml b/.github/workflows/update-version-file-on-release.yml index 679664a..dc29d77 100644 --- a/.github/workflows/update-version-file-on-release.yml +++ b/.github/workflows/update-version-file-on-release.yml @@ -10,7 +10,7 @@ jobs: env: TAG_VERSION: ${{ github.event.release.tag_name }} steps: - # Step 1: Checkout the repository's code + # Step 1: Checkout the original repository's code - name: Checkout code uses: actions/checkout@v4 with: @@ -22,13 +22,7 @@ jobs: git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - # Step 3: Switch to the main branch - - name: Switch to main branch - run: | - git checkout main - git pull origin main - - # Step 4: Check and delete the existing tag (if present) + # Step 3: Check and delete existing tag - name: Check and delete existing tag run: | if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then @@ -36,29 +30,29 @@ jobs: git push --delete origin ${{ env.TAG_VERSION }} # Delete remote tag fi - # Step 5: Update the version file + # Step 4: Update version file - name: Update version file run: | echo "${{ env.TAG_VERSION }}" > version/version # Write the version to the file - # Step 6: Commit and push changes to the main branch + # Step 5: Commit and push changes to the correct branch - name: Commit and push changes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git add version/version git commit -m "Update version to ${{ env.TAG_VERSION }}" - git push origin main # Push to the main branch + git push origin HEAD:${{ github.ref }} # Push to the current branch - # Step 7: Create and push the new tag - - name: Create and push new tag + # Step 6: Create and push new tag + - name: Create and push tag env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git tag ${{ env.TAG_VERSION }} # Create the new tag - git push origin ${{ env.TAG_VERSION }} # Push the tag to the remote repository + git tag ${{ env.TAG_VERSION }} # Create new tag + git push origin ${{ env.TAG_VERSION }} # Push the tag - # Step 8: Find and publish the draft release + # Step 7: Find and Publish Draft Release - name: Find and Publish Draft Release uses: actions/github-script@v6 with: @@ -87,4 +81,4 @@ jobs: core.info(`Draft Release ${draftRelease.tag_name} published successfully.`); } else { core.info("No matching draft release found."); - } + } \ No newline at end of file