Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main 20240409 #106

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update ci
  • Loading branch information
jiqiang90 committed Apr 9, 2024
commit 33b378b1d995bd680971d86cc3946688c467b5d3
6 changes: 3 additions & 3 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:
env:
REPO_TOKEN: ${{ inputs.repo-token }}
shell: bash
106 changes: 53 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,76 @@ 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-near',
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-near',
tag_name: `${packageName[1]}/${version}`,
body: releaseInfo
}).catch( err => {
core.setFailed(err)
})

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

checkForBetaVersion(version);

const releaseInfo = gatherReleaseInfo(`${myArgs[0]}/CHANGELOG.md`);
Expand Down
26 changes: 13 additions & 13 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 Down
5 changes: 5 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
paths-ignore:
- '.github/workflows/**'

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


jobs:
pre-ci:
runs-on: ubuntu-latest
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,38 @@ 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-near'"
if: "!startsWith(needs.pre-ci.outputs.commit-message, '[SKIP CI]') && startsWith(needs.pre-ci.outputs.commit-message, '[release]') && github.repository == 'subquery/subql-near'"
runs-on: ubuntu-latest
steps:
#Check out
Expand Down