Skip to content

Motoko release check #10

Motoko release check

Motoko release check #10

Workflow file for this run

name: Motoko release check
on:
schedule:
- cron: '0 8 * * 1' # Weekly on Monday
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Create GitHub App Token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
with:
client-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_CLIENT_ID }}
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }}
- name: Initialize motoko submodule
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git submodule update --init --depth 1 .sources/motoko
- name: Get latest Motoko release tag
id: latest
run: |
RAW=$(gh release view --repo caffeinelabs/motoko --json tagName -q .tagName)
# git_tag: raw tag as it appears on the remote (no v prefix)
GIT_TAG="${RAW#v}"
# versions_tag: v-prefixed form used in VERSIONS file and PR titles
[[ "$RAW" == v* ]] && VERSIONS_TAG="$RAW" || VERSIONS_TAG="v${RAW}"
echo "git_tag=$GIT_TAG" >> $GITHUB_OUTPUT
echo "versions_tag=$VERSIONS_TAG" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Get currently pinned version
id: current
run: |
CURRENT=$(grep '^motoko ' .sources/VERSIONS | awk '{print $2}')
echo "version=$CURRENT" >> $GITHUB_OUTPUT
- name: Check if update needed
id: check
run: |
LATEST="${{ steps.latest.outputs.versions_tag }}"
CURRENT="${{ steps.current.outputs.version }}"
BRANCH="infra/bump-motoko-${LATEST}"
if [ "$LATEST" = "$CURRENT" ]; then
echo "Already at latest: $CURRENT"
echo "needed=false" >> $GITHUB_OUTPUT
elif git ls-remote --exit-code origin "refs/heads/${BRANCH}" > /dev/null 2>&1; then
echo "Branch $BRANCH already exists — PR likely open, skipping"
echo "needed=false" >> $GITHUB_OUTPUT
else
echo "New release: $LATEST (current: $CURRENT)"
echo "needed=true" >> $GITHUB_OUTPUT
fi
- name: Bump submodule to new release
if: steps.check.outputs.needed == 'true'
run: |
TAG="${{ steps.latest.outputs.git_tag }}"
# Fetch the specific tag shallowly; fall back to fetching all tags if that fails
if ! git -C .sources/motoko fetch --depth 1 origin "refs/tags/${TAG}:refs/tags/${TAG}"; then
git -C .sources/motoko fetch --unshallow --tags origin
fi
git -C .sources/motoko checkout "tags/${TAG}"
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
if: steps.check.outputs.needed == 'true'
with:
node-version: 22
cache: npm
- name: Install dependencies
if: steps.check.outputs.needed == 'true'
run: npm ci
- name: Initialize examples submodule (required for build)
if: steps.check.outputs.needed == 'true'
run: git submodule update --init --depth 1 .sources/examples
- name: Run Motoko sync
if: steps.check.outputs.needed == 'true'
run: npm run sync:motoko
- name: Build check
if: steps.check.outputs.needed == 'true'
run: npm run build
- name: Update VERSIONS file
if: steps.check.outputs.needed == 'true'
run: |
NEW_TAG="${{ steps.latest.outputs.versions_tag }}"
NEW_HASH=$(git -C .sources/motoko rev-parse --short HEAD)
sed -i "s|^motoko .*|motoko ${NEW_TAG} ${NEW_HASH}|" .sources/VERSIONS
- name: Read sync warnings
if: steps.check.outputs.needed == 'true'
id: warnings
run: |
if [ -f /tmp/sync-motoko-warnings.txt ]; then
WARNINGS=$(cat /tmp/sync-motoko-warnings.txt)
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$WARNINGS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "body=" >> $GITHUB_OUTPUT
fi
- name: Create PR
if: steps.check.outputs.needed == 'true'
run: |
git config user.name "pr-automation-bot-public[bot]"
git config user.email "pr-automation-bot-public[bot]@users.noreply.github.com"
BRANCH="infra/bump-motoko-${{ steps.latest.outputs.versions_tag }}"
git checkout -b "$BRANCH"
git add .sources/motoko .sources/VERSIONS docs/languages/motoko/
git commit -m "chore: bump Motoko to ${{ steps.latest.outputs.versions_tag }}"
git push -u origin "$BRANCH"
WARNINGS="${{ steps.warnings.outputs.body }}"
{
echo "## Summary"
echo ""
echo "Automated bump of \`.sources/motoko\` from \`${{ steps.current.outputs.version }}\` to \`${{ steps.latest.outputs.versions_tag }}\`."
echo ""
echo "- Ran \`npm run sync:motoko\` — synced docs from the new release"
echo "- Build passed ✓"
echo ""
if [ -n "$WARNINGS" ]; then
echo "## ⚠️ Warnings — manual review required"
echo ""
echo "$WARNINGS"
echo ""
fi
echo "## Checklist"
echo ""
echo "- [ ] Review synced content for breaking changes"
echo "- [ ] Check [release notes](https://github.com/caffeinelabs/motoko/releases/tag/${{ steps.latest.outputs.git_tag }}) for API or syntax changes that affect hand-written docs"
echo "- [ ] Verify any new sections or renamed files are handled correctly"
echo ""
echo "## Sync recommendation"
echo ""
echo "\`sync from caffeinelabs/motoko doc/md\`"
} > /tmp/pr-body.md
gh pr create \
--title "chore: bump Motoko to ${{ steps.latest.outputs.versions_tag }}" \
--body-file /tmp/pr-body.md
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}