Merge pull request #8 from sanger/main #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Automatically generate a release on develop and main | |
name: Automated release and build of project | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Export node version | |
id: node_version | |
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) | |
- uses: nelonoel/[email protected] | |
- name: Setup node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ steps.node_version.outputs.NODE_VERSION }} | |
registry-url: https://registry.npmjs.org/ | |
- name: Create npm module | |
run: npm pack | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | |
- name: Get current release version from package.json | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@main | |
with: | |
path: ./ | |
- name: Set release tag | |
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable | |
# On the develop branch this might create RELEASE_VERSION=2.4.6-987654321-develop | |
# On the master branch this would then only create RELEASE_VERSION=2.4.6 | |
run: echo "RELEASE_VERSION=$(printf -- '%s%s\n' ${{steps.package-version.outputs.current-version}} $([ ${BRANCH_NAME} = "develop" ] && printf -- '-%s-develop' ${GITHUB_RUN_ID} || echo ""))" >> $GITHUB_ENV | |
- name: Create release | |
uses: ncipollo/[email protected] | |
with: | |
name: ${{ env.RELEASE_VERSION }} | |
tag: v${{ env.RELEASE_VERSION }} | |
artifacts: "sanger-ui-styling-${{ steps.package-version.outputs.current-version}}.tgz" | |
artifactErrorsFailBuild: true | |