Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: release workflow #9677

Merged
merged 6 commits into from Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 20 additions & 3 deletions .github/workflows/build.yml
Expand Up @@ -7,12 +7,19 @@ on:
- v24

workflow_dispatch:
inputs:
dryRun:
description: 'Dry-Run'
default: 'true'

env:
# Currently no way to detect automatically (#8153)
DEFAULT_BRANCH: master
YARN_MODULES_CACHE_KEY: v1
YARN_PACKAGE_CACHE_KEY: v1
YARN_CACHE_FOLDER: .cache/yarn
NODE_VERSION: 14
DRY_RUN: true

jobs:
test:
Expand Down Expand Up @@ -98,7 +105,8 @@ jobs:
uses: codecov/codecov-action@v1.4.1
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
run: yarn build

Expand Down Expand Up @@ -179,6 +187,16 @@ jobs:
yarn config set version-git-tag false
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
- uses: actions/checkout@v2.3.4
with:
Expand All @@ -194,10 +212,9 @@ jobs:
run: yarn install --frozen-lockfile

- name: semantic-release
if: github.ref == 'refs/heads/master'
run: |
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:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37 changes: 30 additions & 7 deletions .github/workflows/release-npm.yml
@@ -1,13 +1,29 @@
name: release-npm

on:
repository_dispatch:
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:
YARN_MODULES_CACHE_KEY: v1
YARN_PACKAGE_CACHE_KEY: v1
YARN_CACHE_FOLDER: .cache/yarn
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:
release-npm:
Expand All @@ -27,9 +43,17 @@ jobs:
yarn config set version-git-tag false
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
with:
ref: ${{ github.event.client_payload.sha }}
ref: ${{ env.GIT_SHA }}

- name: Cache Yarn packages
id: yarn_cache_packages
Expand All @@ -41,17 +65,16 @@ jobs:
- name: Installing dependencies
run: yarn install --frozen-lockfile

- name: Build ${{ github.event.client_payload.version }}
- name: Build ${{ env.NPM_VERSION }}
run: yarn build

- name: Prepare ${{ github.event.client_payload.version }}
- name: Prepare ${{ env.NPM_VERSION }}
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: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ~/.npmrc
npm publish --tag ${TAG:-latest}
npm publish --tag ${NPM_TAG:-latest}
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG: ${{ github.event.client_payload.tag }}