|
| 1 | +name: Create a PR to upgrade WIT to a new version |
| 2 | + |
| 3 | +# Manually dispatch this action from the Actions page |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + prev_version: |
| 8 | + description: 'Upgrading from version (without the v)' |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + next_version: |
| 12 | + description: 'Upgrading to version (without the v)' |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + |
| 16 | +permissions: |
| 17 | + pull-requests: write |
| 18 | + contents: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + update-versions: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + # Checkout the repo and install dependencies |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + - name: Install cargo-binstall |
| 28 | + uses: cargo-bins/[email protected] |
| 29 | + - name: Install wit-bindgen |
| 30 | + shell: bash |
| 31 | + run: cargo binstall wit-bindgen-cli |
| 32 | + - name: Install wit-deps |
| 33 | + shell: bash |
| 34 | + run: cargo binstall wit-deps-cli |
| 35 | + |
| 36 | + # echo input |
| 37 | + - name: Print the versions |
| 38 | + run: echo Upgrading from ${{ inputs.prev_version }} to ${{ inputs.next_version }} |
| 39 | + |
| 40 | + # upgrade |
| 41 | + - name: Upgrade tag |
| 42 | + run: find . -type f -name "*.wit" -exec sed -i "s/${{ inputs.prev_version }}/${{ inputs.next_version }}/g" {} + |
| 43 | + - name: Upgrade wit deps |
| 44 | + run: wit-deps update |
| 45 | + - name: Generate markdown |
| 46 | + run: wit-bindgen markdown wit --html-in-md --all-features |
| 47 | + |
| 48 | + # file PR |
| 49 | + - name: Create feature branch |
| 50 | + env: |
| 51 | + FEATURE_BRANCH: release-v${{ inputs.next_version }} |
| 52 | + run: | |
| 53 | + git config user.name "github-actions[bot]" |
| 54 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 55 | + git add . |
| 56 | + git checkout -b $FEATURE_BRANCH |
| 57 | + git push -u origin $FEATURE_BRANCH |
| 58 | + git commit -m "Update to v${{ inputs.next_version }}" |
| 59 | + git push |
| 60 | +
|
| 61 | + - name: Create pull request |
| 62 | + run: gh pr create -B main -H release-v${{ inputs.next_version }} --title 'Release v${{ inputs.next_version }}' --body 'Updates the package version to v${{ inputs.next_version }}. Thanks!' |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments