From 1672d3af4357a2c393b83f0914c003e1bb3f81c1 Mon Sep 17 00:00:00 2001 From: Arpan Pandey Date: Sun, 19 Oct 2025 17:14:46 +0100 Subject: [PATCH] Add pull request permissions and update install script in GitHub Actions workflow --- .github/workflows/publish.yml | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 539c9e9..b771335 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,6 +6,7 @@ on: permissions: contents: write + pull-requests: write jobs: goreleaser: @@ -33,3 +34,53 @@ jobs: # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' # distribution: # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + update-install-script: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.CODECRAFTERS_BOT_GITHUB_TOKEN }} + + - name: Extract version from tag + id: version + run: | + VERSION="${GITHUB_REF#refs/tags/}" + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Extracted version: $VERSION" + + - name: Update install.sh + run: | + VERSION="${{ steps.version.outputs.version }}" + sed -i.bak "s/VERSION=\${CODECRAFTERS_CLI_VERSION:-v[0-9]*}/VERSION=\${CODECRAFTERS_CLI_VERSION:-$VERSION}/" install.sh + rm install.sh.bak + echo "Updated install.sh with version $VERSION" + + - name: Check for changes + id: changes + run: | + if git diff --quiet install.sh; then + echo "changed=false" >> $GITHUB_OUTPUT + echo "No changes detected" + else + echo "changed=true" >> $GITHUB_OUTPUT + echo "Changes detected:" + git diff install.sh + fi + + - name: Create Pull Request + if: steps.changes.outputs.changed == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.CODECRAFTERS_BOT_GITHUB_TOKEN }} + commit-message: "update default CODECRAFTERS_CLI_VERSION to ${{ steps.version.outputs.version }} in install.sh" + title: "Update CLI version to ${{ steps.version.outputs.version }}" + body: | + This PR automatically updates the default CLI version in `install.sh` to match the newly released version. + + **Version:** ${{ steps.version.outputs.version }} + + This PR was automatically generated by the [publish workflow](https://github.com/${{ github.repository }}/actions/workflows/publish.yml). + branch: update-cli-version-${{ steps.version.outputs.version }} + delete-branch: true