Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
goreleaser:
Expand Down Expand Up @@ -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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unescaped Version Variable in Sed Command

The sed command in the update-install-script job uses the $VERSION variable unescaped in its replacement string. This can cause the command to fail or incorrectly modify install.sh if the version tag contains sed special characters like /, &, or \.

Fix in Cursor Fix in Web

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