chore: Update Motoko #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "chore: Update Motoko" | |
on: | |
workflow_dispatch: | |
inputs: | |
motokoVersion: | |
description: 'Motoko version' | |
default: "latest" | |
sdkBranch: | |
description: 'Open PR against this sdk branch' | |
default: "master" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GH_API_RELEASES_LATEST: "https://api.github.com/repos/dfinity/motoko/releases/latest" | |
# When getting Rust dependencies, retry on network error: | |
CARGO_NET_RETRY: 10 | |
# Use the local .curlrc | |
CURL_HOME: . | |
jobs: | |
update-motoko: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.event.inputs.sdkBranch }} | |
- name: determine Motoko version | |
run: | | |
if [ '${{ github.event.inputs.motokoVersion }}' = 'latest' ]; then | |
echo "MOTOKO_VERSION=$(curl -s "${{ env.GH_API_RELEASES_LATEST }}" | jq -r '.tag_name')" >> $GITHUB_ENV | |
else | |
echo "MOTOKO_VERSION=${{ github.event.inputs.motokoVersion }}" >> $GITHUB_ENV | |
fi | |
grep -s "MOTOKO_VERSION" $GITHUB_ENV | |
- name: install Nix | |
uses: cachix/install-nix-action@v21 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- name: install niv (dependency manager for Nix projects) | |
run: nix-env -i niv -f '<nixpkgs>' | |
- name: install packages from nix/sources.json | |
run: niv update | |
- name: update Motoko | |
run: | | |
echo "updating Motoko" | |
scripts/update-motoko.sh ${{ env.MOTOKO_VERSION }} | |
- name: setup git config, then create new branch and push new commit to it | |
run: | | |
git config author.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | |
git config author.name "${{ github.event.sender.login }}" | |
git config committer.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config committer.name "GitHub Actions Bot" | |
git config user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | |
git config user.name "${{ github.event.sender.login }}" | |
git checkout -b chore-update-motoko-${{ env.MOTOKO_VERSION }} | |
git add . | |
git commit -m "chore: update Motoko version to ${{ env.MOTOKO_VERSION }}" | |
git push origin chore-update-motoko-${{ env.MOTOKO_VERSION }} | |
- name: create Pull Request, with CHANGELOG.md entry suggestion | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.NIV_UPDATER_TOKEN }} # act on behalf of https://github.com/dfinity-bot | |
script: | | |
const { repo, owner } = context.repo; | |
const pr_create_result = await github.rest.pulls.create({ | |
title: `chore: update Motoko version to ${{ env.MOTOKO_VERSION }}`, | |
owner, | |
repo, | |
head: 'chore-update-motoko-${{ env.MOTOKO_VERSION }}', | |
base: '${{ github.event.inputs.sdkBranch }}', | |
body: [ | |
`## Suggested [CHANGELOG.md](https://github.com/${owner}/${repo}/edit/chore-update-motoko-${{ env.MOTOKO_VERSION }}/CHANGELOG.md) changes`, | |
'```', | |
'## Dependencies', | |
'', | |
'### Motoko', | |
'', | |
'Updated Motoko to [${{ env.MOTOKO_VERSION }}](https://github.com/dfinity/motoko/releases/tag/${{ env.MOTOKO_VERSION }})' | |
].join('\n') | |
}); | |
github.rest.issues.addLabels({ | |
owner, | |
repo, | |
issue_number: pr_create_result.data.number, | |
labels: ['chore', 'automerge-squash'] | |
}); | |
core.startGroup('new PR JSON object'); | |
core.info(JSON.stringify(pr_create_result, null, 2)); | |
core.endGroup(); |