CoolFace
Apppublic

hanabhi/gridworld-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
auto-bump-version.yml93 linesDownload Raw Back to workflows
1name: Auto-bump version after release2 3on:4  release:5    types: [published]6 7jobs:8  bump-version:9    runs-on: ubuntu-latest10    permissions:11      contents: write12      pull-requests: write13 14    steps:15      - name: Checkout main16        uses: actions/checkout@v417        with:18          ref: main19          fetch-depth: 020 21      - name: Extract released version from tag22        id: released23        run: |24          TAG="${{ github.event.release.tag_name }}"25          VERSION="${TAG#v}"26          echo "version=$VERSION" >> "$GITHUB_OUTPUT"27 28      - name: Compute next dev version29        id: next30        run: |31          VERSION="${{ steps.released.outputs.version }}"32          MAJOR=$(echo "$VERSION" | cut -d. -f1)33          MINOR=$(echo "$VERSION" | cut -d. -f2)34          PATCH=$(echo "$VERSION" | cut -d. -f3)35          NEXT_PATCH=$((PATCH + 1))36          NEXT_DEV="${MAJOR}.${MINOR}.${NEXT_PATCH}.dev0"37          echo "dev_version=$NEXT_DEV" >> "$GITHUB_OUTPUT"38          echo "branch=bump/${NEXT_DEV}" >> "$GITHUB_OUTPUT"39 40      - name: Verify pyproject.toml shows the released version41        run: |42          CURRENT=$(python3 -c "43          import tomllib44          with open('pyproject.toml', 'rb') as f:45              d = tomllib.load(f)46          print(d['project']['version'])47          ")48          EXPECTED="${{ steps.released.outputs.version }}"49          if [ "$CURRENT" != "$EXPECTED" ]; then50            echo "ERROR: pyproject.toml is '$CURRENT' but release tag is '$EXPECTED'"51            exit 152          fi53 54      - name: Create bump branch and edit pyproject.toml55        env:56          DEV_VERSION: ${{ steps.next.outputs.dev_version }}57          BRANCH: ${{ steps.next.outputs.branch }}58        run: |59          git config user.name "github-actions[bot]"60          git config user.email "github-actions[bot]@users.noreply.github.com"61          git checkout -b "$BRANCH"62          python3 - <<'PYEOF'63          import re, pathlib, os64          dev_version = os.environ["DEV_VERSION"]65          p = pathlib.Path("pyproject.toml")66          text = p.read_text()67          text = re.sub(68              r'^version = ".*"',69              f'version = "{dev_version}"',70              text, count=1, flags=re.MULTILINE,71          )72          p.write_text(text)73          PYEOF74          git add pyproject.toml75          git commit -m "chore: bump version to ${DEV_VERSION} (post-release)"76          git push origin "$BRANCH"77 78      - name: Create pull request79        env:80          GH_TOKEN: ${{ github.token }}81        run: |82          DEV_VERSION="${{ steps.next.outputs.dev_version }}"83          RELEASED="${{ steps.released.outputs.version }}"84          gh pr create \85            --base main \86            --head "${{ steps.next.outputs.branch }}" \87            --title "chore: bump version to ${DEV_VERSION} (post-release)" \88            --body "Automatic post-release bump after ${RELEASED} was published.89 90          **Change**: \`pyproject.toml\` version \`${RELEASED}\` → \`${DEV_VERSION}\`91 92          _Generated by \`.github/workflows/auto-bump-version.yml\`_"93