chore: Add release-please (#631)

* Setup release-please

* Run e2e on merge to main

* Allow builder tag

* Typo

* Fix

* Bump version

* Add bootstrap-sha
This commit is contained in:
Anatolios Laskaris 2023-01-17 15:21:53 +02:00 committed by GitHub
parent 20e0c63e6a
commit 58dd2453a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 281 additions and 158 deletions

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

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

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

@ -0,0 +1,11 @@
{
"bootstrap-sha": "20e0c63e6a6cdb103e417c3d3081ed6ba4c84a97",
"release-type": "simple",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"packages": {
".": {
"component": "aqua"
}
}
}

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

@ -0,0 +1,3 @@
{
".": "0.9.1"
}

View File

@ -1,6 +0,0 @@
{
"template": "## Changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}\n\n${{UNCATEGORIZED}}",
"pr_template": "- #${{NUMBER}} ${{TITLE}}",
"empty_template": "## No changes since ${{FROM_TAG}}",
"sort": "DESC"
}

View File

@ -2,11 +2,11 @@ name: "e2e"
on:
pull_request:
paths-ignode:
paths-ignore:
- "**.md"
push:
branches:
- "master"
- "main"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
@ -28,6 +28,8 @@ jobs:
- name: Setup Scala
uses: coursier/setup-action@v1
with:
apps: sbt
- name: Run tests
run: sbt test

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

@ -0,0 +1,33 @@
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
with:
reporter: github-pr-check
fail_on_error: true

View File

@ -1,170 +1,247 @@
name: "release"
name: "release-please"
on:
workflow_dispatch:
inputs:
do_release:
description: "Set to 'true' to make a GitHub release"
required: true
default: "false"
npm_tag:
description: 'npm tag'
required: true
default: 'latest'
type: choice
options:
- latest
- nightly
push:
branches:
- "main"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
env:
FORCE_COLOR: true
jobs:
release:
name: "Publish ${{ github.event.inputs.do_release == 'true' && 'and release' || 'to NPM' }}"
runs-on: "ubuntu-latest"
env:
DO_RELEASE: ${{ github.event.inputs.do_release || 'false' }}
release-please:
runs-on: ubuntu-latest
outputs:
release-created: ${{ steps.release.outputs.release_created }}
tag-name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}
steps:
- name: Run release-please
id: release
uses: google-github-actions/release-please-action@v3
with:
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
compile:
if: needs.release-please.outputs.release-created
runs-on: builder
needs: release-please
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache Scala
uses: coursier/cache-action@v6
- name: Setup Scala
uses: coursier/setup-action@v1
with:
apps: sbt
- name: JS CLI build
run: sbt cliJS/fullLinkJS
env:
BUILD_NUMBER: ${{ needs.release-please.outputs.version}}
- name: JS API build
run: sbt aqua-api/fullLinkJS
env:
BUILD_NUMBER: ${{ needs.release-please.outputs.version}}
- name: JS LSP build
run: sbt language-server-api/fullLinkJS
env:
BUILD_NUMBER: ${{ needs.release-please.outputs.version}}
- name: Upload aqua-cli artifact
uses: actions/upload-artifact@v3
with:
name: aqua-cli
path: cli/cli/.js/target/scala-*/cli-opt/main.js
- name: Upload aqua-api artifact
uses: actions/upload-artifact@v3
with:
name: aqua-api
path: api/aqua-api/target/scala-*/aqua-api-opt/main.js
- name: Upload aqua-lsp artifact
uses: actions/upload-artifact@v3
with:
name: aqua-lsp
path: language-server/language-server-api/target/scala-*/language-server-api-opt/main.js
aqua-cli:
name: "Publish aqua-cli"
runs-on: ubuntu-latest
needs:
- release-please
- compile
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
### Setup
- uses: olafurpg/setup-scala@v13
- name: JS build
run: sbt cliJS/fullLinkJS
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: JS language server API build
run: sbt language-server-api/fullLinkJS
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: JS Aqua API build
run: sbt aqua-api/fullLinkJS
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: Get project version
# In CI sbt appends a new line after its output, so we need `tail -n3 | head -n2` to get last two non-empty lines
run: |
# Slower way of getting two variables from sbt. Try it if something breaks
#
# VERSION="$(sbt 'print cli/version' |& tail -n2 | head -n1)"
# BASE_VERSION="$(sbt 'print cli/baseAquaVersion' |& tail -n2 | head -n1)"
# print two versions as two lines
OUTPUT=$(sbt 'print cli/baseAquaVersion; print cli/version')
# read two lines to two variables
read -rd "\n" BASE_VERSION VERSION <<<$(echo "$OUTPUT" | tail -n3 | head -n2) || true
# debug output
echo "BASE_VERSION="$BASE_VERSION
echo "VERSION="$VERSION
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: Check .js exists
run: |
JS="cli/cli/.js/target/scala-3.1.3/cli-opt/aqua-${{ env.VERSION }}.js"
mv cli/cli/.js/target/scala-3.1.3/cli-opt/main.js "$JS"
stat "$JS"
echo "JS=$JS" >> $GITHUB_ENV
- name: Check LSP API .js exists
run: |
JSLSP="language-server/language-server-api/target/scala-3.1.3/language-server-api-opt/aqua-${{ env.VERSION }}.js"
mv language-server/language-server-api/target/scala-3.1.3/language-server-api-opt/main.js "$JSLSP"
stat "$JSLSP"
echo "JSLSP=$JSLSP" >> $GITHUB_ENV
- name: Check Aqua API .js exists
run: |
JSAPI="api/aqua-api/target/scala-3.1.3/aqua-api-opt/aqua-${{ env.VERSION }}.js"
mv api/aqua-api/target/scala-3.1.3/aqua-api-opt/main.js "$JSAPI"
stat "$JSAPI"
echo "JSAPI=$JSAPI" >> $GITHUB_ENV
### Publish to NPM registry
- uses: actions/setup-node@v3
- name: Download aqua-cli artifact
uses: actions/download-artifact@v3
with:
node-version: "15"
registry-url: "https://registry.npmjs.org"
name: aqua-cli
- run: cp ${{ env.JS }} ./cli/cli-npm/aqua.js
- run: cp ${{ env.JSLSP }} ./language-server/language-server-npm/aqua-lsp-api.js
- run: cp ${{ env.JSAPI }} ./api/aqua-api-npm/aqua-api.js
- run: mv scala-*/*/main.js cli/cli-npm/aqua.js
- run: npm version ${{ env.VERSION }}
working-directory: ./cli/cli-npm
- name: Publish to NPM as aqua
run: |
npm i
npm run build
npm publish --access public --tag "${{ github.event.inputs.npm_tag }}"
working-directory: ./cli/cli-npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
### create release
# 'Push tag' will fail if such tag already exists
- name: Push tag ${{ env.BASE_VERSION }}
if: ${{ env.DO_RELEASE == 'true' }}
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
- name: Import secrets
uses: hashicorp/vault-action@v2.4.3
with:
custom_tag: ${{ env.BASE_VERSION }}
tag_prefix: ""
github_token: ${{ secrets.PERSONAL_TOKEN }}
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: Build Changelog
if: ${{ env.DO_RELEASE == 'true' }}
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
- name: Setup node
uses: actions/setup-node@v3
with:
configuration: ".github/workflows/changelog_config.json"
toTag: ${{ steps.tag_version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
node-version: "16"
cache-dependency-path: "cli/cli-npm/package-lock.json"
cache: "npm"
- name: Release
if: ${{ env.DO_RELEASE == 'true' }}
uses: softprops/action-gh-release@v1
- name: Set version
run: npm version ${{ needs.release-please.outputs.version }}
working-directory: cli/cli-npm
- run: npm i
working-directory: cli/cli-npm
- name: Publish to NPM registry
run: npm publish --access public
working-directory: cli/cli-npm
aqua-api:
name: "Publish aqua-api"
runs-on: ubuntu-latest
needs:
- release-please
- compile
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download aqua-api artifact
uses: actions/download-artifact@v3
with:
name: Aqua Compiler ${{ env.VERSION }}
tag_name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.github_release.outputs.changelog }}
draft: false
prerelease: false
files: |
${{ env.JS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: aqua-api
- run: npm version ${{ env.VERSION }}
working-directory: ./language-server/language-server-npm
- run: mv scala-*/*/main.js api/aqua-api-npm/aqua-api.js
- name: Publish aqua LSP API to NPM
run: |
npm i
npm publish --access public
working-directory: ./language-server/language-server-npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- 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
- run: npm version ${{ env.VERSION }}
working-directory: ./api/aqua-api-npm
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "16"
cache-dependency-path: "api/aqua-api-npm/package-lock.json"
cache: "npm"
- name: Publish aqua API to NPM
run: |
npm i
npm publish --access public
working-directory: ./api/aqua-api-npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set version
run: npm version ${{ needs.release-please.outputs.version }}
working-directory: api/aqua-api-npm
- run: npm i
working-directory: api/aqua-api-npm
- name: Publish to NPM registry
run: npm publish --access public
working-directory: api/aqua-api-npm
aqua-lsp:
name: "Publish aqua-lsp"
runs-on: ubuntu-latest
needs:
- release-please
- compile
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download aqua-lsp artifact
uses: actions/download-artifact@v3
with:
name: aqua-lsp
- run: mv scala-*/*/main.js language-server/language-server-npm/aqua-lsp-api.js
- 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 node
uses: actions/setup-node@v3
with:
node-version: "16"
cache-dependency-path: "language-server/language-server-npm/package-lock.json"
cache: "npm"
- name: Set version
run: npm version ${{ needs.release-please.outputs.version }}
working-directory: language-server/language-server-npm
- run: npm i
working-directory: language-server/language-server-npm
- name: Publish to NPM registry
run: npm publish --access public
working-directory: language-server/language-server-npm

View File

@ -15,9 +15,9 @@ on:
aqua-version:
description: "@fluencelabs/aqua version"
value: ${{ jobs.aqua.outputs.version }}
aqua-lsp-api-version:
aqua-lsp-version:
description: "@fluencelabs/aqua-language-server-api version"
value: ${{ jobs.aqua-lsp-api.outputs.version }}
value: ${{ jobs.aqua-lsp.outputs.version }}
aqua-api-version:
description: "@fluencelabs/aqua-api version"
value: ${{ jobs.aqua-api.outputs.version }}