Skip to content

Commit

Permalink
ci: migrate release process to NX (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
janivo committed Dec 15, 2023
1 parent 70b0523 commit 5efbbe7
Show file tree
Hide file tree
Showing 31 changed files with 518 additions and 3,705 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-example-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Example Projects

on:
workflow_run:
workflows: [ "Test & Build" ]
workflows: ['Quality Control']
types: [completed]
branches: [master]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-landingpage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/workflows/dependencies-install
- name: Build landingpage ⚒️
run: yarn build:landingpage
run: yarn nx run landingpage:build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/deploy-prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Deploy Pre-Release'

on:
push:
branches:
- master
paths:
- 'packages/elements'
- 'packages/elements-angular'
- 'packages/elements-react'
- 'packages/elements-vue'

jobs:
canary-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org
scope: '@inovex.de' # important for yarn
always-auth: true
- uses: ./.github/workflows/dependencies-install
- name: Setup Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor}}@users.noreply.github.com"
- name: Version
shell: bash
run: yarn nx run workspace:version --configuration=prerelease
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Deploy Release'

on:
- workflow_dispatch

jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org
scope: '@inovex.de' # important for yarn
always-auth: true
- uses: ./.github/workflows/dependencies-install
- name: Setup Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor}}@users.noreply.github.com"
- name: Version
shell: bash
run: yarn nx run workspace:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/deploy-storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Deploy Storybook'

on:
push:
branches:
- master
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
- run: npm config set scripts-prepend-node-path true
- name: Build Storybook
run: yarn nx run storybook:build
- name: Upload Storybook artifact
uses: ./.github/workflows/artifacts-upload
with:
upload-storybook-artifact: true

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout pages branch
uses: actions/checkout@v3
with:
ref: pages
- name: Download Storybook artifact
uses: dawidd6/action-download-artifact@v2
with:
name: storybook
path: version/${{ github.ref_name }} # Push to the proper directory on gh pages branch.
check-artifacts: true # search in current workflow run
workflow-conclusion: 'in_progress' # need to change to in_progress, cause current workflow run is always running
- name: Provide latest symlink
if: ${{ ! contains( github.ref_name, '-' ) }} # only link to latest for releases (e.g. v7.0.0), not pre-releases (e.g. v.7.0.0-1)
run: cd version && rm -f latest && ln -s ${{ github.ref_name }} latest
shell: bash

# Crawls the version dir on current pages branch HEAD.
# Jq extracts the directory name of the versions and transfers it to an array of the form ["0.1.1", "0.2.1"].
- name: Update Hosted Versions
run: find ./version/* -type d -maxdepth 0 | cut -c 11- | jq -R -s -c 'split("\n")[:-1]' > ./hosted-versions.json

- name: Deploy to Github Pages 🚀
uses: JamesIves/[email protected]
with:
branch: pages
commit-message: Deploying version ${{ github.ref_name }} 🚀
folder: '.'
clean: false # Important to keep other versions.
114 changes: 0 additions & 114 deletions .github/workflows/deploy-version.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/prepare-release.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/release-canary.yml

This file was deleted.

64 changes: 21 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test & Build
name: Quality Control

on:
push:
Expand All @@ -8,55 +8,33 @@ on:
types: [opened, synchronize, reopened]

jobs:
build_core:
qc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
- run: yarn nx run-many --target=build --projects=elements* --exclude=*-example
# Build caches for (canary) release workflow
- if: github.ref == 'refs/heads/master'
name: Upload build artifacts for canary release
uses: ./.github/workflows/artifacts-upload
- name: Checkout repository
uses: actions/checkout@v4
with:
upload-core-artifacts: true

lint_n_format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
- run: yarn lint
- run: yarn format

test:
needs:
- build_core
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
- run: yarn build:core
- run: yarn test

build_dependent:
runs-on: ubuntu-latest
needs:
- build_core
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
- run: yarn nx run-many --target=build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts
fetch-depth: 0
- name: Track master branch to make nx affected work
run: |
git branch --track main origin/master
- name: Install dependencies
uses: ./.github/workflows/dependencies-install
- name: Check format
run: yarn format
- name: Check lint
run: yarn lint
- name: Build all projects
run: yarn build
- name: Test all projects
run: yarn test
- name: Upload build artifacts for canary release
uses: ./.github/workflows/artifacts-upload
with:
upload-core-artifacts: true
upload-example-artifacts: ${{ github.ref == 'refs/heads/master' }}
upload-storybook-artifact: true

unicorn:
needs:
- test
- build_dependent
needs: qc
uses: ./.github/workflows/deploy-unicorn.yml
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"affected": {
"defaultBase": "origin/master"
},
"workspaceLayout": {
"appsDir": "packages",
"libsDir": "packages"
Expand Down
Loading

0 comments on commit 5efbbe7

Please sign in to comment.