Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Try to remove the need for a PAT in CI (#15123)

Alex Crichton9efaf66e1218
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index c3ec9bdd83..1114eeb822 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1517,9 +1517,10 @@ jobs:
# "automatically-tag-and-release-this-commit" within merged PRs/commits. Once
# that term is found the current version of `Cargo.toml`, the `wasmtime-cli`
# Cargo.toml, is created as a tag and the tag is pushed to the repo.
- # Currently the tag is created through the GitHub API with an access token to
- # ensure that CI is further triggered for the tag itself which performs the
- # full release process.
+ # The tag is created with the default `GITHUB_TOKEN`, and events created by
+ # that token do not trigger further workflows. The workflows which perform
+ # the actual release, `publish-to-cratesio.yml` and `publish-artifacts.yml`,
+ # are therefore explicitly dispatched on the new tag afterwards.
#
# Note that this depends on the `ci-status` step above which is the "join"
# point of this workflow for when everything succeeds. the purpose of that is
@@ -1535,6 +1536,9 @@ jobs:
&& github.event_name == 'push'
&& startsWith(github.ref, 'refs/heads/release-')
&& github.repository == 'bytecodealliance/wasmtime'
+ permissions:
+ contents: write
+ actions: write
steps:
- uses: actions/checkout@v7
with:
@@ -1555,17 +1559,17 @@ jobs:
echo "push_tag=no" >> $GITHUB_OUTPUT
fi
id: tag
- - name: Push the tag
+ - name: Push the tag and start the release
run: |
- git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
- curl -iX POST $git_refs_url \
- -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
- -d @- << EOF
- {
- "ref": "refs/tags/v${{ steps.tag.outputs.version }}",
- "sha": "${{ steps.tag.outputs.sha }}"
- }
- EOF
+ set -ex
+ tag=v${{ steps.tag.outputs.version }}
+ gh api -X POST repos/${{ github.repository }}/git/refs \
+ -f ref=refs/tags/$tag \
+ -f sha=${{ steps.tag.outputs.sha }}
+ gh workflow run publish-to-cratesio.yml --ref $tag
+ gh workflow run publish-artifacts.yml --ref $tag
+ env:
+ GH_TOKEN: ${{ github.token }}
if: steps.tag.outputs.push_tag == 'yes'
# File an issue on the repo if this run failed and was triggered via
@@ -1581,6 +1585,7 @@ jobs:
always()
&& needs.ci-status.result != 'success'
&& github.event_name == 'workflow_dispatch'
+ && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-'))
permissions:
issues: write
steps:
diff --git a/.github/workflows/publish-artifacts.yml b/.github/workflows/publish-artifacts.yml
index 8c2d419af0..040ab202d6 100644
--- a/.github/workflows/publish-artifacts.yml
+++ b/.github/workflows/publish-artifacts.yml
@@ -3,6 +3,7 @@ on:
push:
branches: [main]
tags-ignore: [dev]
+ workflow_dispatch:
permissions:
contents: write
diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.yml
index 5d949e1945..00197c0fce 100644
--- a/.github/workflows/publish-to-cratesio.yml
+++ b/.github/workflows/publish-to-cratesio.yml
@@ -8,6 +8,7 @@ on:
push:
tags:
- 'v*'
+ workflow_dispatch:
permissions:
id-token: write
diff --git a/.github/workflows/release-process.yml b/.github/workflows/release-process.yml
index e222ee285a..b76a06671b 100644
--- a/.github/workflows/release-process.yml
+++ b/.github/workflows/release-process.yml
@@ -37,6 +37,8 @@ on:
permissions:
contents: write
+ pull-requests: write
+ actions: write
jobs:
release_process:
@@ -51,7 +53,6 @@ jobs:
run: |
git config user.name 'Wasmtime Publish'
git config user.email '[email protected]'
- git remote set-url origin https://git:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.repository }}
- uses: ./.github/actions/install-rust
- uses: ./.github/actions/cargo-install
@@ -64,7 +65,7 @@ jobs:
github.event.schedule == '0 0 5 * *' ||
github.event.inputs.action == 'cut'
env:
- GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+ GH_TOKEN: ${{ github.token }}
run: |
set -ex
# The `main` branch always carries a `-dev` version. Strip that suffix
@@ -79,6 +80,7 @@ jobs:
# Push the current contents of `main` to a new release branch
git push origin HEAD:$branch
+ gh workflow run main.yml --ref $branch
# Update version numbers and make a commit indicating that. Note that
# on merge this will not trigger a publish.
@@ -126,6 +128,7 @@ jobs:
--base main \
--title "Bump Wasmtime to $num" \
--body-file pr-body-main
+ gh workflow run main.yml --ref ci/bump-to-$num
# Now go back to where the release branch was cut and prepare the
# first release candidate for it.
@@ -151,13 +154,14 @@ jobs:
--base $branch \
--title "Release Wasmtime $rc" \
--body-file pr-body-rc
+ gh workflow run main.yml --ref ci/rc-$rc
- name: Perform latest release
if: >-
github.event.schedule == '0 0 20 * *' ||
github.event.inputs.action == 'release-latest'
env:
- GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+ GH_TOKEN: ${{ github.token }}
run: |
set -ex
git fetch origin
@@ -195,11 +199,12 @@ jobs:
--base release-$cur \
--title "Release Wasmtime $cur" \
--body-file pr-body
+ gh workflow run main.yml --ref ci/release-$cur
- name: Release a new release candidate
if: github.event.inputs.action == 'release-rc'
env:
- GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+ GH_TOKEN: ${{ github.token }}
run: |
set -ex
# Move to the next release candidate for this branch. Note that this
@@ -226,11 +231,12 @@ jobs:
--base ${{ github.ref_name }} \
--title "Release Wasmtime $rc" \
--body-file pr-body
+ gh workflow run main.yml --ref ci/rc-$rc
- name: Bump and release patch version number
if: github.event.inputs.action == 'release-patch'
env:
- GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+ GH_TOKEN: ${{ github.token }}
run: |
set -ex
# Update version numbers on a patch basis and update RELEASES.md if a
@@ -262,3 +268,4 @@ jobs:
--base ${{ github.ref_name }} \
--title "Release Wasmtime $num" \
--body-file pr-body
+ gh workflow run main.yml --ref ci/bump-to-$num