Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update wit version workflow #99

Merged
merged 1 commit into from
Feb 6, 2025
Merged
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
64 changes: 64 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Create a PR to upgrade WIT to a new version

# Manually dispatch this action from the Actions page
on:
workflow_dispatch:
inputs:
prev_version:
description: 'Upgrading from version (without the v)'
required: true
type: string
next_version:
description: 'Upgrading to version (without the v)'
required: true
type: string

permissions:
pull-requests: write
contents: write

jobs:
print-versions:
runs-on: ubuntu-latest
steps:
# Checkout the repo and install dependencies
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
- name: Install wit-bindgen
shell: bash
run: cargo binstall wit-bindgen-cli
- name: Install wit-deps
shell: bash
run: cargo binstall wit-deps-cli

# echo input
- name: Print the versions
run: echo Upgrading from ${{ inputs.prev_version }} to ${{ inputs.next_version }}

# upgrade
- name: Upgrade tag
run: find . -type f -name "*.wit" -exec sed -i "s/${{ inputs.prev_version }}/${{ inputs.next_version }}/g" {} +
# - name: Upgrade wit deps
# run: wit-deps update
- name: Generate markdown
run: wit-bindgen markdown wit --html-in-md --all-features

# file PR
- name: Create feature branch
env:
FEATURE_BRANCH: v${{ inputs.next_version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git checkout -b $FEATURE_BRANCH
git push -u origin $FEATURE_BRANCH
git commit -m "Update to v${{ inputs.next_version }}"
git push

- name: Create pull request
run: gh pr create -B main -H v${{ inputs.next_version }} --title 'Release v${{ inputs.next_version }}' --body 'Updates the package version to v${{ inputs.next_version }}. Thanks!'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}