# Combined workflow to build and create release
## It's an hack until https://github.community/t/triggering-a-new-workflow-from-another-workflow/16250/24 is solved by Github
---
name: Build and Release
on:
push:
branches:
- master
jobs:
build:
name: Create Release branch and Tag
runs-on: ubuntu-latest
outputs:
tag: "v${{ steps.vars.outputs.pkg_version }}"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: "12"
- name: npm install
uses: bahmutov/npm-install@v1
- name: Build package
run: npm run build
- name: Get package version
id: vars
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=pkg_version::$(node -e "console.log(require('./package.json').version);")"
- name: Add & Commit
uses: EndBug/add-and-commit@v4.2.0
with:
add: "dist"
force: true
message: "Built ${{ steps.vars.outputs.sha_short }}"
ref: "release/v${{ steps.vars.outputs.pkg_version }}"
tag: "v${{ steps.vars.outputs.pkg_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by Github Actions
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by Github Actions
with:
tag_name: ${{ needs.build.outputs.tag }}
release_name: Release ${{ needs.build.outputs.tag }}
draft: false
prerelease: false