From 048a2cc4d2c1a871c360205074401bbfc6972290 Mon Sep 17 00:00:00 2001 From: Yosh Date: Thu, 6 Feb 2025 16:09:25 +0100 Subject: [PATCH] Add update github action --- .github/workflows/publish.yml | 4 +-- .github/workflows/update.yml | 64 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/update.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e7aa6eb..90109fb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: permissions: id-token: write packages: write - contents: read + contents: write steps: # Checkout the repo and install dependencies @@ -45,7 +45,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.ORG_PAT }} # Build our `.wit` files into a Wasm binary - name: Build diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..bdf61d3 --- /dev/null +++ b/.github/workflows/update.yml @@ -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: + update-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/cargo-binstall@v1.10.15 + - 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: release-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 release-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 }}