|
| 1 | +name: "Release: Bump Version" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + bump-version: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + permissions: |
| 11 | + contents: write |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | + env: |
| 15 | + BRANCH: ci/bump-version |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Create GitHub App token |
| 22 | + uses: actions/create-github-app-token@v2 |
| 23 | + id: app-token |
| 24 | + with: |
| 25 | + app-id: ${{ vars.APP_ID }} |
| 26 | + private-key: ${{ secrets.APP_KEY }} |
| 27 | + |
| 28 | + - name: Get GitHub App User ID |
| 29 | + id: get-user-id |
| 30 | + shell: bash |
| 31 | + run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" |
| 32 | + env: |
| 33 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 34 | + |
| 35 | + - name: Git Config |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' |
| 39 | + git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' |
| 40 | +
|
| 41 | + - name: Bump Version |
| 42 | + id: bump-version |
| 43 | + env: |
| 44 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 45 | + COMMIT: "ci: bump version for release :rocket:" |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + if git show-ref --quiet refs/heads/${BRANCH}; then |
| 49 | + echo "Branch ${BRANCH} already exists." |
| 50 | + git branch -D "${BRANCH}" |
| 51 | + git push origin --delete "${BRANCH}" |
| 52 | + fi |
| 53 | + git checkout -b "${BRANCH}" |
| 54 | + DATE=$(date +%Y-%m-%d) |
| 55 | + VERSION=$(date +%Y.%m.%d) |
| 56 | + sed -i "s/^version:.*/version: ${VERSION}/" CITATION.cff |
| 57 | + sed -i "s/^date-released:.*/date-released: \"${DATE}\"/" CITATION.cff |
| 58 | + git add CITATION.cff || echo "No changes to add" |
| 59 | + git commit -m "${COMMIT}" || echo "No changes to commit" |
| 60 | + git push --force origin ${BRANCH} || echo "No changes to push" |
| 61 | +
|
| 62 | + - name: Create Pull Request |
| 63 | + shell: bash |
| 64 | + env: |
| 65 | + GH_TOKEN: ${{ steps.app-token.outputs.token }} |
| 66 | + run: | |
| 67 | + sleep 20 |
| 68 | + gh pr create --fill-first --base "main" --head "${BRANCH}" --label "Type: CI/CD :robot:" |
| 69 | + sleep 5 |
| 70 | + gh pr merge --auto --squash --delete-branch |
0 commit comments