mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
168 lines
5.3 KiB
YAML
168 lines
5.3 KiB
YAML
name: "release"
|
|
|
|
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
|
|
|
|
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' }}
|
|
|
|
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
|
|
with:
|
|
node-version: "15"
|
|
registry-url: "https://registry.npmjs.org"
|
|
|
|
- run: cp ${{ env.JS }} ./cli-npm/aqua.js
|
|
- run: cp ${{ env.JSLSP }} ./language-server-npm/aqua-lsp-api.js
|
|
- run: cp ${{ env.JSAPI }} ./aqua-api-npm/aqua-api.js
|
|
|
|
- run: npm version ${{ env.VERSION }}
|
|
working-directory: ./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
|
|
with:
|
|
custom_tag: ${{ env.BASE_VERSION }}
|
|
tag_prefix: ""
|
|
github_token: ${{ secrets.PERSONAL_TOKEN }}
|
|
|
|
- name: Build Changelog
|
|
if: ${{ env.DO_RELEASE == 'true' }}
|
|
id: github_release
|
|
uses: mikepenz/release-changelog-builder-action@v3
|
|
with:
|
|
configuration: ".github/workflows/changelog_config.json"
|
|
toTag: ${{ steps.tag_version.outputs.new_tag }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Release
|
|
if: ${{ env.DO_RELEASE == 'true' }}
|
|
uses: softprops/action-gh-release@v1
|
|
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 }}
|
|
|
|
- run: npm version ${{ env.VERSION }}
|
|
working-directory: ./language-server/language-server-npm
|
|
|
|
- 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: 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 }}
|
|
|