chore: Add release-please (#240)

* Add release-please

* Fix

* Fix ci.js

* Rename fluence-js

* Run pnpm i

* Fix

* Update workflows

* Fix
This commit is contained in:
Anatolios Laskaris 2023-02-15 16:45:04 +02:00 committed by GitHub
parent 0d05e517d8
commit 63a3579ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 344 additions and 84 deletions

3
.github/actionlint.yaml vendored Normal file
View File

@ -0,0 +1,3 @@
self-hosted-runner:
labels:
- builder

18
.github/release-please/config.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"release-type": "node",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"plugins": [
{
"type": "node-workspace"
}
],
"packages": {
"packages/client/api": {},
"packages/js-client.node": {},
"packages/js-client.web.standalone": {},
"packages/tools": {},
"packages/core/interfaces": {},
"packages/core/js-peer": {}
}
}

8
.github/release-please/manifest.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"packages/client/api": "0.10.0",
"packages/js-client.node": "0.5.0",
"packages/js-client.web.standalone": "0.12.0",
"packages/tools": "0.1.0",
"packages/core/interfaces": "0.6.0",
"packages/core/js-peer": "0.7.0"
}

View File

@ -1,5 +0,0 @@
{
"template": "${{CHANGELOG}}\n\n${{UNCATEGORIZED}}",
"pr_template": "- #${{NUMBER}} ${{TITLE}}",
"empty_template": "- no changes"
}

View File

@ -4,9 +4,19 @@ on:
pull_request:
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/e2e.yml"
- "!.github/workflows/tests.yml"
- "!.github/workflows/snapshot.yml"
push:
branches:
- "master"
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/e2e.yml"
- "!.github/workflows/tests.yml"
- "!.github/workflows/snapshot.yml"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"

35
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: lint
on:
pull_request:
types:
- opened
- edited
- synchronize
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
pr:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
reviewdog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Lint actions
uses: reviewdog/action-actionlint@v1
env:
SHELLCHECK_OPTS: "-e SC2086 -e SC2207 -e SC2128"
with:
reporter: github-pr-check
fail_on_error: true

168
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,168 @@
name: "release-please"
on:
push:
branches:
- "master"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
env:
CI: true
FORCE_COLOR: true
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release-created: ${{ steps.release.outputs.releases_created }}
pr: ${{ steps.release.outputs.pr }}
steps:
- name: Run release-please
id: release
uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }}
command: manifest
config-file: .github/release-please/config.json
manifest-file: .github/release-please/manifest.json
- name: Show output from release-please
if: steps.release.outputs.releases_created
env:
RELEASE_PLEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }}
run: echo "${RELEASE_PLEASE_OUTPUT}" | jq
bump-version:
if: needs.release-please.outputs.pr != null
runs-on: ubuntu-latest
needs:
- release-please
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }}
token: ${{ secrets.FLUENCEBOT_RELEASE_PLEASE_PAT }}
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 7
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
- run: pnpm i --no-frozen-lockfile
- name: Commit version bump
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: Regenerate pnpm lock file"
branch: ${{ fromJson(needs.release-please.outputs.pr).headBranchName }}
commit_user_name: fluencebot
commit_user_email: devops@fluence.one
commit_author: fluencebot <devops@fluence.one>
fluence-js:
if: needs.release-please.outputs.release-created
runs-on: ubuntu-latest
needs:
- release-please
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Import secrets
uses: hashicorp/vault-action@v2.4.3
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/npmjs/fluencebot token | NODE_AUTH_TOKEN
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 7
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
- run: pnpm i
- run: pnpm -r build
- name: Publish to npm registry
run: pnpm --no-git-checks -r publish -filter '@fluencelabs/*' --access public --tags unstable
slack:
if: always()
name: "Notify"
runs-on: ubuntu-latest
needs:
- release-please
- fluence-js
permissions:
contents: read
id-token: write
steps:
- uses: lwhiteley/dependent-jobs-result-check@v1
id: status
with:
statuses: failure
dependencies: ${{ toJSON(needs) }}
- name: Log output
run: |
echo "statuses:" "${{ steps.status.outputs.statuses }}"
echo "jobs:" "${{ steps.status.outputs.jobs }}"
echo "found any?:" "${{ steps.status.outputs.found }}"
- name: Import secrets
uses: hashicorp/vault-action@v2.4.3
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/slack/release-please webhook | SLACK_WEBHOOK_URL
- uses: ravsamhq/notify-slack-action@v2
if: steps.status.outputs.found == 'true'
with:
status: "failure"
notification_title: "*{workflow}* has {status_message}"
message_format: "${{ steps.status.outputs.jobs }} {status_message} in <{repo_url}|{repo}>"
footer: "<{run_url}>"

View File

@ -1,27 +1,29 @@
name: Run tests with worflow_call
name: "ci"
on:
workflow_call:
inputs:
rust-peer-image:
description: "rust-peer image tag"
type: string
default: "fluencelabs/fluence:minimal"
avm-version:
description: "@fluencelabs/avm version"
type: string
default: "null"
marine-js-version:
description: "@fluencelabs/marine-js version"
type: string
default: "null"
ref:
description: "git ref to checkout to"
type: string
default: "master"
pull_request:
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/e2e.yml"
- "!.github/workflows/tests.yml"
- "!.github/workflows/snapshot.yml"
push:
branches:
- "master"
paths-ignore:
- "**.md"
- ".github/**"
- "!.github/workflows/e2e.yml"
- "!.github/workflows/tests.yml"
- "!.github/workflows/snapshot.yml"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
env:
RUST_PEER_IMAGE: "${{ inputs.rust-peer-image }}"
RUST_PEER_IMAGE: "fluencelabs/fluence:minimal"
FORCE_COLOR: true
CI: true
@ -39,6 +41,7 @@ jobs:
node-version:
- 16.x
- 17.x
- 18.x
steps:
- name: Import secrets
@ -63,9 +66,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
repository: fluencelabs/fluence-js
ref: ${{ inputs.ref }}
- name: Pull rust-peer image
run: docker pull $RUST_PEER_IMAGE
@ -90,23 +90,5 @@ jobs:
- run: pnpm i
- name: Set avm version
if: inputs.avm-version != 'null'
uses: fluencelabs/github-actions/npm-set-dependency@main
with:
package: "@fluencelabs/avm"
version: ${{ inputs.avm-version }}
working-directory: packages/fluence-js
package-manager: pnpm
- name: Set marine-js version
if: inputs.marine-js-version != 'null'
uses: fluencelabs/github-actions/npm-set-dependency@main
with:
package: "@fluencelabs/marine-js"
version: ${{ inputs.marine-js-version }}
working-directory: packages/fluence-js
package-manager: pnpm
- run: pnpm -r build
- run: pnpm -r test

View File

@ -1,8 +1,4 @@
name: Run tests
defaults:
run:
working-directory: .
name: Run tests with worflow_call
on:
workflow_call:
@ -22,7 +18,7 @@ on:
ref:
description: "git ref to checkout to"
type: string
default: "v0.28.0"
default: "master"
env:
RUST_PEER_IMAGE: "${{ inputs.rust-peer-image }}"
@ -34,32 +30,83 @@ jobs:
name: "Run tests"
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
matrix:
node-version: [16.x, 17.x, 18.x]
node-version:
- 16.x
- 17.x
steps:
- uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- name: Import secrets
uses: hashicorp/vault-action@v2.4.3
with:
node-version: ${{ matrix.node-version }}
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
secrets: |
kv/docker-registry/basicauth/ci username | DOCKER_USERNAME ;
kv/docker-registry/basicauth/ci password | DOCKER_PASSWORD
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: docker.fluence.dev
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Checkout
uses: actions/checkout@v3
with:
repository: fluencelabs/fluence-js
ref: ${{ inputs.ref }}
- name: Pull rust-peer image
run: docker pull $RUST_PEER_IMAGE
- name: Run rust-peer
uses: isbang/compose-action@v1.4.1
with:
compose-file: ".github/e2e/docker-compose.yml"
down-flags: "--volumes"
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 7
- name: Run container with Fluence node
run: |
docker pull fluencelabs/fluence
docker run -d --rm -e RUST_LOG="info" -p 1210:1210 -p 4310:4310 fluencelabs/fluence -t 1210 -w 4310 -k gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj --local --aqua-pool-size 2
- name: Setup node ${{ matrix.node-version }} with self-hosted registry
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://npm.fluence.dev"
cache: "pnpm"
- run: pnpm i
- name: Set avm version
if: inputs.avm-version != 'null'
uses: fluencelabs/github-actions/npm-set-dependency@main
with:
package: "@fluencelabs/avm"
version: ${{ inputs.avm-version }}
working-directory: packages/fluence-js
package-manager: pnpm
- name: Set marine-js version
if: inputs.marine-js-version != 'null'
uses: fluencelabs/github-actions/npm-set-dependency@main
with:
package: "@fluencelabs/marine-js"
version: ${{ inputs.marine-js-version }}
working-directory: packages/fluence-js
package-manager: pnpm
- run: pnpm -r build
env:
CI: true
- run: pnpm -r test
env:
CI: true

9
ci.js
View File

@ -74,12 +74,7 @@ function processDep(obj, name, fn) {
return;
}
if (!/^workspace\:/.test(obj[name])) {
return;
}
const version = obj[name].replace("workspace:", "");
fn(obj, version);
fn(obj, obj[name]);
}
async function getVersionsMap(allPackageJsons) {
return new Map(await Promise.all(allPackageJsons.map(getVersion)));
@ -125,7 +120,7 @@ async function bumpVersions(file, versionsMap) {
// bump dependencies
for (const [name, version] of versionsMap) {
const update = (x) => (x[name] = `workspace:${version}-${postfix}`);
const update = (x) => (x[name] = `${version}-${postfix}`);
processDep(json.dependencies, name, update);
processDep(json.devDependencies, name, update);
}

View File

@ -1,3 +1,2 @@
packages:
- 'packages/**/*'