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

Commit

Permalink
Add new Ink Version update support (#815)
Browse files Browse the repository at this point in the history
* 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
radhe-zeeve authored Feb 1, 2024
1 parent cde28bb commit beaace9
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 2 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/ink_version_update.yml
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/ink_versions.json
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"
]
7 changes: 7 additions & 0 deletions scripts/generate_ink_releases.sh
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
19 changes: 19 additions & 0 deletions scripts/update_ink_version_to_latest.sh
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}

0 comments on commit beaace9

Please sign in to comment.