aqua/.github/workflows/release.yml
2021-05-28 19:04:33 +03:00

100 lines
3.1 KiB
YAML

name: "release"
on:
push:
# uncomment to release only on tags starting with 'v'
# tags:
# - "v*"
branches:
- "main"
workflow_dispatch:
inputs:
draft:
description: "Whether to create draft or actual release. 'false' by default, put 'true' to make draft release"
required: false
default: false
jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
steps:
- name: Checkout repository
uses: actions/checkout@v2
### Setup
- uses: olafurpg/setup-scala@v10
### Update & build
- name: Assembly
run: sbt cli/assembly
env:
BUILD_NUMBER: ${{ github.run_number }}
### Create release
- 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 .jar exists
run: |
JAR="cli/target/scala-2.13/aqua-cli-${{ env.VERSION }}.jar"
stat "$JAR"
echo "JAR=$JAR" >> $GITHUB_ENV
### 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
- uses: marvinpinto/action-automatic-releases@latest
with:
# changelog will be automatically generated from the history
# between tag env.BASE_VERSION (eg 0.1.0 or 0.2.0, etc)
# and the current commit
automatic_release_tag: "${{ env.BASE_VERSION }}"
title: "Aqua Compiler ${{ env.VERSION }}"
files: |
${{ env.JAR }}
body: |
[${{ env.VERSION }} @ NPM registry](https://www.npmjs.com/package/${{ env.PKG_NAME }}/v/${{ env.VERSION }})
draft: ${{ github.event.inputs.draft }}
prerelease: false
repo_token: "${{ secrets.GITHUB_TOKEN }}"