|
| 1 | +name: IRISCAST Bump, Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump-type: |
| 7 | + description: 'Bump type' |
| 8 | + required: true |
| 9 | + default: 'patch' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - major |
| 13 | + - minor |
| 14 | + - patch |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + release: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: "Setup Github Token" |
| 25 | + uses: actions/create-github-app-token@v2 |
| 26 | + id: app-token |
| 27 | + with: |
| 28 | + app-id: ${{ vars.APP_ID }} |
| 29 | + private-key: ${{ secrets.PRIVATE_KEY }} |
| 30 | + |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up Python |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: "3.11" |
| 38 | + |
| 39 | + - name: Setting up git config |
| 40 | + shell: bash |
| 41 | + env: |
| 42 | + GH_TOKEN: "${{ steps.app-token.outputs.token }}"e |
| 43 | + run: | |
| 44 | + git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" |
| 45 | + git config --global user.name "$(gh api /users/${GITHUB_ACTOR} | jq .name -r)" |
| 46 | + git config -l |
| 47 | +
|
| 48 | + - name: Install bump-my-version |
| 49 | + shell: bash |
| 50 | + run: pip install "bump-my-version" |
| 51 | + |
| 52 | + - name: Pass Inputs to Shell |
| 53 | + id: bump |
| 54 | + shell: bash |
| 55 | + working-directory: ./iriscasttools |
| 56 | + run: | |
| 57 | + echo "previous-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT |
| 58 | +
|
| 59 | + bump-my-version bump ${{ inputs.bump-type }} |
| 60 | + ([[ $? -gt 0 ]] && echo "bumped=false" || echo "bumped=true") >> $GITHUB_OUTPUT |
| 61 | + echo "current-version=$(bump-my-version show current_version)" >> $GITHUB_OUTPUT |
| 62 | + |
| 63 | + - name: Push changes to GitHub |
| 64 | + uses: ad-m/github-push-action@master |
| 65 | + with: |
| 66 | + github_token: "${{ steps.app-token.outputs.token }}" |
| 67 | + branch: master |
| 68 | + force: true |
| 69 | + |
| 70 | + - name: Check |
| 71 | + if: steps.bump.outputs.bumped == 'true' |
| 72 | + run: | |
| 73 | + echo "Version was bumped from ${{ steps.bump.outputs.previous-version }} to ${{ steps.bump.outputs.current-version }}!" |
| 74 | +
|
| 75 | + - name: Build package |
| 76 | + if: steps.bump.outputs.bumped == 'true' |
| 77 | + run: | |
| 78 | + pip install build |
| 79 | + python -m build |
| 80 | +
|
| 81 | + - name: Create GitHub Release |
| 82 | + if: steps.bump.outputs.bumped == 'true' |
| 83 | + uses: softprops/action-gh-release@v2 |
| 84 | + with: |
| 85 | + tag_name: iriscasttools-v${{ steps.bump.outputs.current-version }} |
| 86 | + name: Release ${{ steps.bump.outputs.current-version }} |
| 87 | + files: iriscasttools/dist/* |
| 88 | + token: "${{ steps.app-token.outputs.token }}" |
| 89 | + |
| 90 | + |
0 commit comments