Skip to content
Snippets Groups Projects
Unverified Commit dca841b9 authored by Michael Kriese's avatar Michael Kriese Committed by GitHub
Browse files

build: release workflow update (#9677)

parent 3516c705
No related branches found
No related tags found
No related merge requests found
...@@ -7,12 +7,19 @@ on: ...@@ -7,12 +7,19 @@ on:
- v24 - v24
workflow_dispatch: workflow_dispatch:
inputs:
dryRun:
description: 'Dry-Run'
default: 'true'
env: env:
# Currently no way to detect automatically (#8153)
DEFAULT_BRANCH: master
YARN_MODULES_CACHE_KEY: v1 YARN_MODULES_CACHE_KEY: v1
YARN_PACKAGE_CACHE_KEY: v1 YARN_PACKAGE_CACHE_KEY: v1
YARN_CACHE_FOLDER: .cache/yarn YARN_CACHE_FOLDER: .cache/yarn
NODE_VERSION: 14 NODE_VERSION: 14
DRY_RUN: true
jobs: jobs:
test: test:
...@@ -98,7 +105,8 @@ jobs: ...@@ -98,7 +105,8 @@ jobs:
uses: codecov/codecov-action@v1.4.1 uses: codecov/codecov-action@v1.4.1
if: always() && env.coverage == 'true' if: always() && env.coverage == 'true'
# build after tests to exclude files # build after tests to exclude build files from tests
# TODO: check if build before test speeds up tests
- name: Build - name: Build
run: yarn build run: yarn build
...@@ -179,6 +187,16 @@ jobs: ...@@ -179,6 +187,16 @@ jobs:
yarn config set version-git-tag false yarn config set version-git-tag false
npm config set scripts-prepend-node-path true npm config set scripts-prepend-node-path true
- name: Check dry run
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" && "${{ github.event.inputs.dryRun }}" != "true" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" == "refs/heads/${{env.DEFAULT_BRANCH}}" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" =~ ^refs/heads/v[0-9]+(\.[0-9]+)?$ ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
fi
# full checkout for semantic-release # full checkout for semantic-release
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
with: with:
...@@ -194,10 +212,9 @@ jobs: ...@@ -194,10 +212,9 @@ jobs:
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: semantic-release - name: semantic-release
if: github.ref == 'refs/heads/master'
run: | run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc
npx semantic-release --dry-run ${{github.ref != 'refs/heads/master'}} --ci ${{github.ref == 'refs/heads/master'}} npx semantic-release --dry-run ${{env.DRY_RUN}}
env: env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
name: release-npm name: release-npm
on: on:
repository_dispatch: repository_dispatch:
types: [renovate-release] types: [renovate-release]
workflow_dispatch:
inputs:
sha:
description: 'Git sha to checkout'
required: true
version:
description: 'Version to release'
required: true
tag:
description: 'Npm dist-tag'
default: 'latest'
env: env:
YARN_MODULES_CACHE_KEY: v1 YARN_MODULES_CACHE_KEY: v1
YARN_PACKAGE_CACHE_KEY: v1 YARN_PACKAGE_CACHE_KEY: v1
YARN_CACHE_FOLDER: .cache/yarn YARN_CACHE_FOLDER: .cache/yarn
NODE_VERSION: 14 NODE_VERSION: 14
GIT_SHA: ${{ github.event.client_payload.sha }}
NPM_VERSION: ${{ github.event.client_payload.version }}
NPM_TAG: ${{ github.event.client_payload.tag }}
jobs: jobs:
release-npm: release-npm:
...@@ -27,9 +43,17 @@ jobs: ...@@ -27,9 +43,17 @@ jobs:
yarn config set version-git-tag false yarn config set version-git-tag false
npm config set scripts-prepend-node-path true npm config set scripts-prepend-node-path true
- name: Prepare env
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
echo "GIT_SHA=${{ github.event.inputs.sha }}" >> $GITHUB_ENV
echo "NPM_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
echo "NPM_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
fi
- uses: actions/checkout@v2.3.4 - uses: actions/checkout@v2.3.4
with: with:
ref: ${{ github.event.client_payload.sha }} ref: ${{ env.GIT_SHA }}
- name: Cache Yarn packages - name: Cache Yarn packages
id: yarn_cache_packages id: yarn_cache_packages
...@@ -41,17 +65,16 @@ jobs: ...@@ -41,17 +65,16 @@ jobs:
- name: Installing dependencies - name: Installing dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
- name: Build ${{ github.event.client_payload.version }} - name: Build ${{ env.NPM_VERSION }}
run: yarn build run: yarn build
- name: Prepare ${{ github.event.client_payload.version }} - name: Prepare ${{ env.NPM_VERSION }}
run: | run: |
npm --no-git-tag-version version ${{ github.event.client_payload.version }} npm --no-git-tag-version version ${{ env.NPM_VERSION }}
- name: Publish ${{ github.event.client_payload.version }} - name: Publish ${{ env.NPM_VERSION }}
run: | run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc
npm publish --tag ${TAG:-latest} npm publish --tag ${NPM_TAG:-latest}
env: env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG: ${{ github.event.client_payload.tag }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment