2021-03-22 12:38:31 +00:00
|
|
|
name: "release"
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-03-22 12:45:50 +00:00
|
|
|
# uncomment to release only on tags starting with 'v'
|
2021-03-22 12:38:31 +00:00
|
|
|
# tags:
|
|
|
|
# - "v*"
|
|
|
|
branches:
|
2021-03-22 12:39:43 +00:00
|
|
|
- "main"
|
2021-03-22 12:38:31 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
### 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
|
|
|
|
|
|
|
### Create release
|
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: |
|
2021-04-14 11:15:27 +00:00
|
|
|
JAR="cli/target/scala-2.13/aqua-cli-${{ env.VERSION }}.jar"
|
|
|
|
stat "$JAR"
|
2021-03-22 13:55:07 +00:00
|
|
|
echo "JAR=$JAR" >> $GITHUB_ENV
|
|
|
|
|
2021-04-14 15:00:51 +00:00
|
|
|
### Publish to NPM registry
|
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: "14"
|
|
|
|
registry-url: "https://registry.npmjs.org"
|
|
|
|
|
|
|
|
- name: Install jq and prepare package
|
|
|
|
run: |
|
|
|
|
sudo apt-get update && sudo apt-get --yes --force-yes install jq
|
|
|
|
PKG_NAME="$(cat package.json | jq -r .name)"
|
|
|
|
cp ${{ env.JAR }} ./npm/aqua-cli.jar
|
|
|
|
|
|
|
|
- run: npm version ${{ env.VERSION }}
|
|
|
|
working-directory: ./npm
|
|
|
|
|
|
|
|
- run: npm publish --access public
|
|
|
|
working-directory: ./npm
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
|
|
|
|
### create release
|
2021-03-22 12:38:31 +00:00
|
|
|
- uses: marvinpinto/action-automatic-releases@latest
|
|
|
|
with:
|
2021-03-22 13:55:07 +00:00
|
|
|
# changelog will be automatically generated from the history
|
2021-04-14 11:15:27 +00:00
|
|
|
# between tag env.BASE_VERSION (eg 0.1.0 or 0.2.0, etc)
|
2021-03-22 13:55:07 +00:00
|
|
|
# and the current commit
|
2021-04-14 11:15:27 +00:00
|
|
|
automatic_release_tag: "${{ env.BASE_VERSION }}"
|
2021-03-22 13:55:07 +00:00
|
|
|
title: "Aqua Compiler ${{ env.VERSION }}"
|
2021-03-22 12:38:31 +00:00
|
|
|
files: |
|
2021-03-22 13:55:07 +00:00
|
|
|
${{ env.JAR }}
|
2021-04-14 15:00:51 +00:00
|
|
|
body: |
|
|
|
|
[${{ env.VERSION }} @ NPM registry](https://www.npmjs.com/package/${{ env.PKG_NAME }}/v/${{ env.VERSION }})
|
2021-03-22 13:55:07 +00:00
|
|
|
draft: true
|
|
|
|
prerelease: false
|
|
|
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|