This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new Ink Version update support (#815)
* add version update support Signed-off-by: Jasti Sri Radhe Shyam <[email protected]> * add pipefail in ink version update, so that script failed on first error encounter Signed-off-by: Jasti Sri Radhe Shyam <[email protected]> --------- Signed-off-by: Jasti Sri Radhe Shyam <[email protected]>
- Loading branch information
1 parent
cde28bb
commit beaace9
Showing
5 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Ink_Version_Update | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 6 * * *' | ||
|
||
jobs: | ||
get_versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
components: rustfmt | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install jq | ||
run: sudo apt -y install jq | ||
- name: Fetch versions | ||
run: bash ./scripts/generate_ink_releases.sh | ||
- name: Show versions | ||
run: cat ./config/ink_versions.json | ||
- name: Generate versions variables and PR name | ||
id: version_info | ||
run: | | ||
latest_ink_version=$(cat ./config/ink_versions.json | jq -r '.[0]') | ||
echo "ink_version_changed=$(git diff --quiet -- ./config/ink_versions.json && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT | ||
echo "latest_ink_version=${latest_ink_version}" >> $GITHUB_OUTPUT | ||
echo "ink_update_pr_name=[auto-generated] add new ink version: ${latest_ink_version}" >> $GITHUB_OUTPUT | ||
- name: Update contract | ||
if: ${{ steps.version_info.outputs.ink_version_changed == 'true' }} | ||
run: bash ./scripts/update_ink_version_to_latest.sh | ||
- name: Commit | ||
if: ${{ steps.version_info.outputs.ink_version_changed == 'true' }} | ||
run: | | ||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git status | ||
git add ./Cargo.lock | ||
git add ./config/ink_versions.json | ||
git add ./crates | ||
git commit -m "update ink version list, latest version: ${{ steps.version_info.outputs.latest_ink_version }}" | ||
- name: Duplicate PR check | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const prName = '${{ steps.version_info.outputs.ink_update_pr_name }}' | ||
const otherPRs = await github.graphql(` | ||
query { | ||
repository(owner: "${{ github.repository_owner }}", name: "ink-playground") { | ||
pullRequests(labels: ["INK_VERSION"], last: 100, states: [MERGED, OPEN]) { | ||
edges { | ||
node { | ||
title | ||
labels(first: 100) { | ||
nodes { | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
console.log({otherPRs}) | ||
const otherPRsWithSameNameAndLabels = otherPRs.repository.pullRequests.edges.filter(edge => { | ||
const otherPrName = edge.node.title; | ||
return prName === otherPrName; | ||
}); | ||
if (otherPRsWithSameNameAndLabels.length > 0) { | ||
throw new Error('Open PR name and label must be unique'); | ||
} | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: Update report | ||
committer: GitHub <[email protected]> | ||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
signoff: false | ||
branch: ink-version-${{ steps.version_info.outputs.latest_ink_version }} | ||
delete-branch: true | ||
title: ${{ steps.version_info.outputs.ink_update_pr_name }} | ||
body: | | ||
Update report | ||
- Updated the Ink version to ${{ steps.version_info.outputs.latest_ink_version }} | ||
- Auto-generated by [create-pull-request][1] | ||
[1]: https://github.com/peter-evans/create-pull-request | ||
labels: | | ||
INK_VERSION | ||
github_actions | ||
draft: false |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
"4.2.0", | ||
"4.1.0", | ||
"4.0.1", | ||
"4.0.0" | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
relative_dirname="$(dirname -- "${BASH_SOURCE[0]}")" | ||
bash_dir_path="$(cd -- "${relative_dirname}" && pwd)" | ||
config_path=${bash_dir_path}/../config | ||
ink_versions_list_path=${config_path}/ink_versions.json | ||
|
||
# This is provide stable version of Ink | ||
curl -s https://crates.io/api/v1/crates/ink | jq '[ .versions[] | { num } | .num ] | map(select(. != "0.0.0")) | map(select(index("-") < 0))' > $ink_versions_list_path |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
set -o pipefail | ||
|
||
relative_dirname="$(dirname -- "${BASH_SOURCE[0]}")" | ||
bash_dir_path="$(cd -- "${relative_dirname}" && pwd)" | ||
|
||
config_path=${bash_dir_path}/../config | ||
ink_versions_list_path=${config_path}/ink_versions.json | ||
|
||
contract_dir=${bash_dir_path}/../crates/contract | ||
cd ${contract_dir} | ||
|
||
ink_latest_version=$(cat ${ink_versions_list_path} | jq -r '.[0]') | ||
cargo install cargo-edit | ||
cargo set-version --package contract "${ink_latest_version}" | ||
cargo add --package contract ink@${ink_latest_version} | ||
cargo add --package contract --dev ink_e2e@${ink_latest_version} |