aqua/.github/workflows/release.yml

142 lines
4.4 KiB
YAML
Raw Normal View History

2021-03-22 12:38:31 +00:00
name: "release"
on:
2021-04-13 10:37:03 +00:00
workflow_dispatch:
2021-03-22 12:38:31 +00:00
jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
steps:
- name: Checkout repository
uses: actions/checkout@v2
### Setup
- uses: olafurpg/setup-scala@v10
- name: Download jq
run: |
curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -o /usr/local/bin/jq
chmod +x /usr/local/bin/jq
2021-03-22 12:38:31 +00:00
### Update & build
2021-03-22 12:45:50 +00:00
- name: Assembly
2021-04-08 12:53:54 +00:00
run: sbt cli/assembly
2021-04-14 11:15:27 +00:00
env:
BUILD_NUMBER: ${{ github.run_number }}
2021-03-22 12:38:31 +00:00
- name: JS build
run: sbt cliJS/fullLinkJS
env:
BUILD_NUMBER: ${{ github.run_number }}
2021-03-22 13:55:07 +00:00
- name: Get project version
2021-04-14 11:15:27 +00:00
# In CI sbt appends a new line after its output, so we need `tail -n3 | head -n2` to get last two non-empty lines
2021-03-22 13:55:07 +00:00
run: |
2021-04-14 11:15:27 +00:00
# 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)"
2021-03-22 13:55:07 +00:00
2021-04-14 11:15:27 +00:00
# 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 .jar exists
2021-03-22 13:55:07 +00:00
run: |
JAR="cli/.jvm/target/scala-3.0.1/aqua-cli-${{ env.VERSION }}.jar"
2021-04-14 11:15:27 +00:00
stat "$JAR"
2021-03-22 13:55:07 +00:00
echo "JAR=$JAR" >> $GITHUB_ENV
- name: Check .js exists
run: |
JS="cli/.js/target/scala-3.0.1/cli-opt/aqua-cli-experimental-${{ env.VERSION }}.js"
mv cli/.js/target/scala-3.0.1/cli-opt/main.js "$JS"
stat "$JS"
echo "JS=$JS" >> $GITHUB_ENV
### Publish to NPM registry
- uses: actions/setup-node@v1
with:
node-version: "15"
registry-url: "https://registry.npmjs.org"
- run: cp ${{ env.JAR }} ./npm/aqua-cli.jar
- run: cp ${{ env.JS }} ./npm/aqua-cli-experimental.js
- run: npm version ${{ env.VERSION }}
working-directory: ./npm
- name: Publish to NPM as aqua-cli
run: npm publish --access public
working-directory: ./npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to NPM as aqua
run: |
CONTENTS="$(jq '.name = "@fluencelabs/aqua"' package.json)"
echo "$CONTENTS" > package.json
npm publish --access public
working-directory: ./npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
### create release
- name: Remove tag if exists
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ env.BASE_VERSION }}"
})
} catch (e) {
console.log("The ${{ env.BASE_VERSION }} tag doesn't exist yet: " + e)
}
- name: Push tag ${{ env.BASE_VERSION }}
id: tag_version
uses: mathieudutour/github-tag-action@v5.5
with:
custom_tag: ${{ env.BASE_VERSION }}
tag_prefix: ""
github_token: ${{ secrets.PERSONAL_TOKEN }}
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
2021-03-22 12:38:31 +00:00
with:
configuration: ".github/workflows/changelog_config.json"
toTag: ${{ steps.tag_version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
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
2021-03-22 13:55:07 +00:00
prerelease: false
files: |
${{ env.JAR }}
${{ env.JS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}