Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit beaace9

Browse files
authored
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]>
1 parent cde28bb commit beaace9

File tree

5 files changed

+135
-2
lines changed

5 files changed

+135
-2
lines changed
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Ink_Version_Update
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 6 * * *'
7+
8+
jobs:
9+
get_versions:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Install Rust toolchain
13+
uses: actions-rs/toolchain@v1
14+
with:
15+
profile: minimal
16+
toolchain: nightly
17+
components: rustfmt
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Install jq
21+
run: sudo apt -y install jq
22+
- name: Fetch versions
23+
run: bash ./scripts/generate_ink_releases.sh
24+
- name: Show versions
25+
run: cat ./config/ink_versions.json
26+
- name: Generate versions variables and PR name
27+
id: version_info
28+
run: |
29+
latest_ink_version=$(cat ./config/ink_versions.json | jq -r '.[0]')
30+
echo "ink_version_changed=$(git diff --quiet -- ./config/ink_versions.json && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT
31+
echo "latest_ink_version=${latest_ink_version}" >> $GITHUB_OUTPUT
32+
echo "ink_update_pr_name=[auto-generated] add new ink version: ${latest_ink_version}" >> $GITHUB_OUTPUT
33+
- name: Update contract
34+
if: ${{ steps.version_info.outputs.ink_version_changed == 'true' }}
35+
run: bash ./scripts/update_ink_version_to_latest.sh
36+
- name: Commit
37+
if: ${{ steps.version_info.outputs.ink_version_changed == 'true' }}
38+
run: |
39+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
40+
git config --global user.name "github-actions[bot]"
41+
git status
42+
git add ./Cargo.lock
43+
git add ./config/ink_versions.json
44+
git add ./crates
45+
git commit -m "update ink version list, latest version: ${{ steps.version_info.outputs.latest_ink_version }}"
46+
- name: Duplicate PR check
47+
uses: actions/github-script@v6
48+
with:
49+
script: |
50+
const prName = '${{ steps.version_info.outputs.ink_update_pr_name }}'
51+
const otherPRs = await github.graphql(`
52+
query {
53+
repository(owner: "${{ github.repository_owner }}", name: "ink-playground") {
54+
pullRequests(labels: ["INK_VERSION"], last: 100, states: [MERGED, OPEN]) {
55+
edges {
56+
node {
57+
title
58+
labels(first: 100) {
59+
nodes {
60+
name
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}
68+
`);
69+
70+
console.log({otherPRs})
71+
72+
const otherPRsWithSameNameAndLabels = otherPRs.repository.pullRequests.edges.filter(edge => {
73+
const otherPrName = edge.node.title;
74+
return prName === otherPrName;
75+
});
76+
77+
if (otherPRsWithSameNameAndLabels.length > 0) {
78+
throw new Error('Open PR name and label must be unique');
79+
}
80+
- name: Create Pull Request
81+
id: cpr
82+
uses: peter-evans/create-pull-request@v5
83+
with:
84+
token: ${{ secrets.GITHUB_TOKEN }}
85+
commit-message: Update report
86+
committer: GitHub <[email protected]>
87+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
88+
signoff: false
89+
branch: ink-version-${{ steps.version_info.outputs.latest_ink_version }}
90+
delete-branch: true
91+
title: ${{ steps.version_info.outputs.ink_update_pr_name }}
92+
body: |
93+
Update report
94+
- Updated the Ink version to ${{ steps.version_info.outputs.latest_ink_version }}
95+
- Auto-generated by [create-pull-request][1]
96+
97+
[1]: https://github.com/peter-evans/create-pull-request
98+
labels: |
99+
INK_VERSION
100+
github_actions
101+
draft: false

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/ink_versions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
"4.2.0",
3+
"4.1.0",
4+
"4.0.1",
5+
"4.0.0"
6+
]

scripts/generate_ink_releases.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
relative_dirname="$(dirname -- "${BASH_SOURCE[0]}")"
2+
bash_dir_path="$(cd -- "${relative_dirname}" && pwd)"
3+
config_path=${bash_dir_path}/../config
4+
ink_versions_list_path=${config_path}/ink_versions.json
5+
6+
# This is provide stable version of Ink
7+
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
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
set -o pipefail
5+
6+
relative_dirname="$(dirname -- "${BASH_SOURCE[0]}")"
7+
bash_dir_path="$(cd -- "${relative_dirname}" && pwd)"
8+
9+
config_path=${bash_dir_path}/../config
10+
ink_versions_list_path=${config_path}/ink_versions.json
11+
12+
contract_dir=${bash_dir_path}/../crates/contract
13+
cd ${contract_dir}
14+
15+
ink_latest_version=$(cat ${ink_versions_list_path} | jq -r '.[0]')
16+
cargo install cargo-edit
17+
cargo set-version --package contract "${ink_latest_version}"
18+
cargo add --package contract ink@${ink_latest_version}
19+
cargo add --package contract --dev ink_e2e@${ink_latest_version}

0 commit comments

Comments
 (0)