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

ci: provide elements release by pull request #715

Merged
merged 21 commits into from
Sep 13, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/dependencies-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ author: 'Benjamin Pagelsdorf'
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
Expand Down
51 changes: 24 additions & 27 deletions .github/workflows/deploy-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,38 @@ name: 'Publish Release & Deploy'
## The version is available at elements.inovex.de/version/<TAG-NAME>

on:
workflow_dispatch:
workflow_run:
workflows: [ "Test & Build" ]
types: [completed]
branches: [master]

jobs:
build:
tag_and_release:
if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.event.head_commit.message, format('chore{0} publish v', ':')) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
- run: yarn build
- uses: ./.github/workflows/artifacts-upload
with:
upload-core-artifacts: true
upload-storybook-artifact: true
- name: Create version tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

publish:
runs-on: ubuntu-latest
needs:
- build
- tag_and_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.RELEASE_PAT }}
- 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
- name: restore lerna cache
uses: actions/cache@v3
id: lerna-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- uses: ./.github/workflows/dependencies-install
- uses: ./.github/workflows/artifacts-download
with:
workflow-id: ${{ github.event.workflow_run.workflow_id }}
download-core-artifacts: true
- name: Prepare git config
run: |
Expand All @@ -51,18 +47,19 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

deploy:
runs-on: ubuntu-latest
needs:
- publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout to gh-pages branch
with:
ref: gh-pages
- uses: rlespinasse/[email protected]
- name: Download Storybook artifact
uses: actions/download-artifact@v3
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: storybook
path: version/${{ env.GITHUB_REF_NAME_SLUG }} # Push to the proper directory on gh pages branch.
- name: Provide latest symlink
Expand Down
41 changes: 21 additions & 20 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# This is a basic workflow to help you get started with Actions
name: 'Prepare Release'

name: CI

# Controls when the workflow will run
on:
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
version:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

# Runs a set of commands using the runners shell
- name: Run a multi-line script
with:
fetch-depth: 0
- uses: ./.github/workflows/dependencies-install
- name: Prepare git config
run: |
echo Add other actions to build,
echo test, and deploy your project.
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor}}@users.noreply.github.com"
- name: Bump version and create changelog
run: lerna version --conventional-commits
- name: Set new version as env
run: echo "elements_version=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: elements-release-${{ env.elements_version }}
delete-branch: true
labels: release
base: master
title: ${{ format('chore{0} publish v{1}', ':', env.elements_version) }}
body: ""
2 changes: 1 addition & 1 deletion .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:

jobs:
canary-release:
if: ${{ github.event.workflow_run.conclusion == 'success' && !(startsWith(github.event.head_commit.message, format('chore{0} v', ':')) && endsWith(github.event.head_commit.message, ' publish')) }}
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/dependencies-install
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ jobs:
- run: npm config set scripts-prepend-node-path true
- run: yarn build

# Build caches for release-canary workflow
# Build caches for (canary) release workflow
- if: github.ref == 'refs/heads/master'
name: Upload all build artifacts
uses: ./.github/workflows/artifacts-upload
with:
upload-core-artifacts: true
upload-example-artifacts: true
upload-storybook-artifact: true
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"command": {
"version": {
"yes": true,
"push": true,
"push": false,
"message": "chore: publish %s",
"allowBranch": "master"
"allowBranch": ["master", "elements-release-*"]
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"publish:yalc": "node ./scripts/publishYalc.js",
"publish:canary": "yarn lerna publish --no-verify-access --canary --exact --preid next.$(git rev-parse --short HEAD) --force-publish",
"publish:npm": "yarn lerna publish --conventional-commits --preid test.$(git rev-parse --short HEAD)",
"publish:ci": "yarn lerna publish --conventional-commits --no-verify-access --create-release github --yes",
"publish:ci": "yarn lerna publish --amend --conventional-commits --no-changelog --no-git-tag-version --no-verify-access --yes",
"version": "node scripts/bumprootversion.js",
"postversion": "git add -A"
},
Expand Down