Skip to content

Commit

Permalink
setup auto prs (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
osipov-mit authored Dec 4, 2024
1 parent 321dc5b commit d668f6d
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 29 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/CI-self-hosted.yml

This file was deleted.

8 changes: 7 additions & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ jobs:
with:
node-version: 20.x

- name: Last gear release
id: gear_release
run: |
VERSION=$(curl -s https://api.github.com/repos/gear-tech/gear/releases/latest | jq -r '.tag_name')
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download Gear node [release=build]
run: |
wget -O ./gear https://github.com/gear-tech/gear/releases/download/build/gear
wget -O ./gear https://github.com/gear-tech/gear/releases/download/${{ steps.gear_release.outputs.version }}/gear
chmod +x ./gear
- name: Install rosetta-cli tool
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Create Release

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
if: github.event.head_commit.message =~ '^v\d.\d.\d$'

steps:
- name: Checkout code
uses: actions/checkout@master

- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.head_commit.message }}
release_name: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
10 changes: 5 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Create Release

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag for release'
description: "Tag for release"
required: true
release_name:
description: 'Release name'
required: true

name: Create Release
description: "Release name"
required: true

jobs:
build:
Expand Down
82 changes: 82 additions & 0 deletions .github/workflows/renew.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Renew configs

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
check_release:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.release.outputs.skip }}
version: ${{ steps.gear_release.outputs.version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Last gear release
id: gear_release
run: |
VERSION=curl -s https://api.github.com/repos/gear-tech/gear/releases/latest | jq -r '.tag_name'
echo "version=VERSION" >> $GITHUB_OUTPUT
- name: Last rosetta release
id: rosetta_release
run: |
VERSION=curl -s https://api.github.com/repos/gear-foundation/integrations-rosetta-api/releases/latest | jq -r '.tag_name'
echo "version=VERSION" >> $GITHUB_OUTPUT
- name: Compare versions
id: release
run: |
if [ ${{ steps.gear_release.outputs.version }} == ${{ steps.rosetta_release.outputs.version }} ]; then
echo "No new version to release"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "New version to release"
echo "skip=false" >> $GITHUB_OUTPUT
fi
create_pr:
runs-on: ubuntu-latest
needs: check-release
if: needs.check_release.outputs.skip != 'true'
env:
VERSION: ${{ needs.check_release.outputs.version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: "Install NodeJS 20.x"
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: "Update metadata"
run: |
node ./scripts/renew-config.js ${{ needs.check_release.outputs.version }}
- name: New PR branch
id: new-branch
run: |
NAME="$BRANCH_PREFIX-${{ github.event.inputs.tag }}"
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: Create Pull Request if not exist
id: cpr
uses: peter-evans/create-pull-request@v4
with:
commit-message: add new vara config
branch: ${{ steps.new-branch.outputs.name }}
delete-branch: true
base: master
title: "[Automated] ${{ needs.check_release.outputs.version }}"
add-paths: |
config/*
body: |
"Automated renew configs for version ${{ needs.check_release.outputs.version }}"
draft: false
reviewers: osipov-mit
18 changes: 14 additions & 4 deletions scripts/renew-config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
const assert = require('assert');
const fs = require('fs');

const TESTNET_CONFIG_PATH = './config/rosetta/vara-testnet.json';
const MAINNET_CONFIG_PATH = './config/rosetta/vara-mainnet.json';

const tag = process.argv[2];
const version = process.argv[3];
let tag = process.argv[2];

const testnet_meta_url = `https://github.com/gear-tech/gear/releases/download/v${tag}/testnet_vara_runtime_v${version}_metadata.scale`;
if (!tag.startsWith('v')) {
tag = `v${tag}`;
}

const production_meta_url = `https://github.com/gear-tech/gear/releases/download/v${tag}/production_vara_runtime_v${version}_metadata.scale`;
assert.strictEqual(tag.match(/^v\d+\.\d+\.\d+$/), tag);

const version = tag.slice(1).replaceAll('.', '') + '0';

assert.strictEqual(version.length, 4);

const testnet_meta_url = `https://github.com/gear-tech/gear/releases/download/${tag}/testnet_vara_runtime_v${version}_metadata.scale`;

const production_meta_url = `https://github.com/gear-tech/gear/releases/download/${tag}/production_vara_runtime_v${version}_metadata.scale`;

const main = async () => {
console.log('Downloading testnet metadata from', testnet_meta_url);
Expand Down

0 comments on commit d668f6d

Please sign in to comment.