Skip to content

Commit

Permalink
Sync main 20240408 (#110)
Browse files Browse the repository at this point in the history
* sync with main

* update headers

* changelog

* fixes

* Fix workers

* Fix test

* update ci

* Update test

* Update .github/actions/create-release/gh-release-script.js

Co-authored-by: Scott Twiname <[email protected]>

---------

Co-authored-by: Scott Twiname <[email protected]>
  • Loading branch information
jiqiang90 and stwiname authored Apr 9, 2024
1 parent cfac1b6 commit 136fa84
Show file tree
Hide file tree
Showing 80 changed files with 624 additions and 899 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = {
2,
'line',
[
//Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
//Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
{pattern: ' Copyright \\d{4}(-\\d{4})? SubQuery Pte Ltd authors & contributors'},
' SPDX-License-Identifier: GPL-3.0',
],
Expand Down
8 changes: 4 additions & 4 deletions .github/actions/create-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ inputs:
npm-token:
description: 'token to push to npm registry'
required: true

runs:
using: "composite"
steps:
- working-directory: ${{ inputs.package-path }}
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
run: echo "Changes exist in ${{ inputs.package-path }}" && yarn npm publish --access public
env:
NPM_TOKEN: ${{ inputs.npm-token }}
shell: bash

- working-directory: ${{ github.workspace }}
run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }}
env:
run: node ${{ github.action_path }}/gh-release-script.js ${{ github.workspace }}/${{ inputs.package-path }} ${{ github.sha }}
env:
REPO_TOKEN: ${{ inputs.repo-token }}
shell: bash
107 changes: 54 additions & 53 deletions .github/actions/create-release/gh-release-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,76 +8,77 @@ const myArgs = process.argv.slice(2);
const pJson = require(`${myArgs[0]}/package.json`)

const version = pJson.version;
const repoName = pJson.name;
const repoName = pJson.name;

const packageName = repoName.split('/');

function checkForBetaVersion(version) {
if (version.includes('-')){
exit(0); //skip this package but continue trying to release others
}
if (version.includes('-')){
exit(0); //skip this package but continue trying to release others
}
}

function gatherReleaseInfo(logPath) {
const changeLogs = fs.readFileSync(logPath, 'utf8');
const regex = /## \[([0-9]+(\.[0-9]+)+)] - [0-9]{4}-[0-9]{2}-[0-9]{2}/i;

let lines = changeLogs.split(/\n/);
let foundChangelog = false;
let releaseInfo = '';
let i = 0;
const changeLogs = fs.readFileSync(logPath, 'utf8');
const regex = /## \[([0-9]+(\.[0-9]+)+)] - [0-9]{4}-[0-9]{2}-[0-9]{2}/i;

for(let j = 0; j < lines.length; j++){
if(lines[j].includes(`[${version}]`)){
i = j;
j = lines.length;
foundChangelog = true;
}
}
let lines = changeLogs.split(/\n/);
let foundChangelog = false;
let releaseInfo = '';
let i = 0;

lines = lines.slice(i);

if(foundChangelog){
for(let j = 0; j < lines.length; j++){
if(j == 0){
releaseInfo += `${lines[j]}`+ '\n';
continue;
}

if(!regex.test(lines[j])){
releaseInfo += `${lines[j]}`+ '\n';
} else {
j = lines.length;
}
}
for(let j = 0; j < lines.length; j++){
if(lines[j].includes(`[${version}]`)){
i = j;
j = lines.length;
foundChangelog = true;
}

if(releaseInfo === ''){
core.setFailed("No release info found, either missing in changelog or changelog is formatted incorrectly")
}

lines = lines.slice(i);

if(foundChangelog){
for(let j = 0; j < lines.length; j++){
if(j == 0){
releaseInfo += `${lines[j]}`+ '\n';
continue;
}

if(!regex.test(lines[j])){
releaseInfo += `${lines[j]}`+ '\n';
} else {
j = lines.length;
}
}
}

if(releaseInfo === ''){
core.setFailed("No release info found, either missing in changelog or changelog is formatted incorrectly")
}

console.log("Gathered release info...")
return releaseInfo;
console.log("Gathered release info...")
return releaseInfo;
}

async function publishRelease(releaseInfo) {

await request('POST /repos/{owner}/{repo}/releases', {
headers: {
authorization: `token ${process.env.REPO_TOKEN}`,
},
owner: 'subquery',
name: `[${version}] ${repoName}`,
repo: 'subql-algorand',
tag_name: `${packageName[1]}/${version}`,
body: releaseInfo
}).catch( err => {
core.setFailed(err)
})

console.log("Release Created...")
await request('POST /repos/{owner}/{repo}/releases', {
headers: {
authorization: `token ${process.env.REPO_TOKEN}`,
},
owner: 'subquery',
name: `[${version}] ${repoName}`,
repo: 'subql-algorand',
tag_name: `${packageName[1]}/${version}`,
target_commitish: `${myArgs[1]}`,
body: releaseInfo
}).catch( err => {
core.setFailed(err)
})

console.log("Release Created...")
}

checkForBetaVersion(version);

const releaseInfo = gatherReleaseInfo(`${myArgs[0]}/CHANGELOG.md`);
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/node-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
if [[ $COMMIT_MESSAGE == "[release]"* ]] && git diff --name-only HEAD~1 HEAD -- './packages/node/package.json'
then
echo "::set-output name=changes_found::true"
echo "::set-output name=changes_found::true" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=changes_found::false"
echo "::set-output name=changes_found::false" >> "$GITHUB_OUTPUT"
fi
else
echo "::set-output name=changes_found::true"
echo "::set-output name=changes_found::true" >> "$GITHUB_OUTPUT"
fi
node-build-push-docker:
Expand All @@ -46,13 +46,13 @@ jobs:
token: ${{ secrets.REPO_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: onfinality
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -69,7 +69,7 @@ jobs:

- name: Build and push
if: github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'false'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -80,7 +80,7 @@ jobs:

- name: Build and push
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'true')
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -104,13 +104,13 @@ jobs:
token: ${{ secrets.REPO_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: subquerynetwork
password: ${{ secrets.SQ_DOCKERHUB_TOKEN }}
Expand All @@ -127,7 +127,7 @@ jobs:

- name: Build and push
if: github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'false'
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -138,7 +138,7 @@ jobs:

- name: Build and push
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'true')
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -149,4 +149,3 @@ jobs:

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

4 changes: 4 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
paths-ignore:
- '.github/workflows/**'

concurrency:
group: publish
cancel-in-progress: false

jobs:
pre-ci:
runs-on: ubuntu-latest
Expand Down
29 changes: 22 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,37 @@ on:
- '.github/workflows/**'
workflow_dispatch:

concurrency:
# Same group as prerelease
group: publish
cancel-in-progress: false

jobs:
# This gets the commit message because workflow dispatch doesnt set: github.event.head_commit.message
pre-ci:
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
commit-message: ${{ steps.step1.outputs.commit-message }}
steps:
- name: 'Block Concurrent Executions'
uses: softprops/turnstyle@v1
- uses: actions/checkout@v4
with:
poll-interval-seconds: 10
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
fetch-depth: 100

# Get the commit message, workflow_dispatch doesn't contain it so we need to get it through git cli
- id: step1
run: |
if [ -n "${{ github.event.head_commit.message }}" ]
then
echo "commit-message=${{ github.event.head_commit.message }}" >> "$GITHUB_OUTPUT"
else
echo "commit-message=$(git log -1 --pretty=%B)" >> "$GITHUB_OUTPUT"
fi
Build-Publish:
name: Build-Publish
needs: pre-ci
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]') && startsWith(github.event.head_commit.message, '[release]') && github.repository == 'subquery/subql-algorand'"
if: "!startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]') && startsWith(needs.pre-ci.outputs.commit-message, '[release]') && github.repository == 'subquery/subql-algorand'"
runs-on: ubuntu-latest
steps:
#Check out
Expand All @@ -35,7 +50,7 @@ jobs:
with:
node-version: 18

#Identify changes
#Identify changes
- uses: marceloprado/has-changed-path@v1
id: changed-types
with:
Expand Down
3 changes: 3 additions & 0 deletions packages/common-algorand/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- version bump with `@subql/common`

## [3.2.2] - 2024-02-23
### Changed
- version bump with `@subql/common`
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"main": "dist/index.js",
"license": "GPL-3.0",
"dependencies": {
"@subql/common": "^3.4.1",
"@subql/common": "^3.5.0",
"@subql/types-algorand": "workspace:*",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

export * from './project';
2 changes: 1 addition & 1 deletion packages/common-algorand/src/project/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

export * from './load';
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/src/project/load.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {AlgorandProjectManifestVersioned, VersionedProjectManifest} from './versioned';
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/src/project/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {BaseDataSource, ProcessorImpl} from '@subql/common';
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/src/project/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {AlgorandDataSource} from '@subql/types-algorand';
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/src/project/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {registerDecorator, ValidationOptions} from 'class-validator';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {AlgorandDataSource} from '@subql/types-algorand';
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/src/project/versioned/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

export * from './ProjectManifestVersioned';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

export * from './model';
Loading

0 comments on commit 136fa84

Please sign in to comment.