Skip to content

Commit

Permalink
build: adapt release process
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation committed Nov 15, 2023
1 parent 3ccf91a commit c5793ea
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 105 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,17 @@ jobs:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive
- name: Run build
run: yarn generate:chromatic-stories && yarn build:storybook
- name: Generate chromatic stories
run: yarn generate:chromatic-stories
- uses: actions/github-script@v6
id: version
with:
script: |
const sha = context.payload.pull_request?.head.sha ?? context.sha;
return `${require('./package.json').version}-rev.${sha.substring(0, 10)}`;
result-encoding: string
- name: Create versioned storybook for chromatic
run: STORYBOOK_COMPONENTS_VERSION=${{ steps.version.outputs.result }} yarn build:storybook
env:
CHROMATIC: true
- name: Publish to Chromatic
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Release Please
on:
push:
branches:
- master

# Documentation:
# https://github.com/googleapis/release-please
# https://github.com/google-github-actions/release-please-action
# https://github.com/googleapis/release-please/blob/main/docs/customizing.md

permissions:
contents: write
packages: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.release.outputs.releases_created }}
version: ${{ steps.release.outputs.version }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
bump-minor-pre-major: true
bump-patch-for-minor-pre-major: true
# Un/comment to enable/disable
prerelease: true
- name: Release Info
run: echo "${{ steps.release.outputs }}"

release:
needs: release-please
if: needs.release-please.outputs.releases_created
runs-on: ubuntu-latest
env:
IMAGE_REPO: ghcr.io/${{ github.repository_owner }}/server
VERSION: ${{ needs.release-please.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: sbb-esta
- run: yarn install --frozen-lockfile --non-interactive

- name: Run build
run: STORYBOOK_COMPONENTS_VERSION=$VERSION yarn build
- name: 'Release: Determine npm tag'
id: npm_tag
run: echo "npm_tag=$([[ "$VERSION" == *"-"* ]] && echo "next" || echo "latest")" >> $GITHUB_OUTPUT
- name: 'Release: Publish @sbb-esta/lyne-components'
run: yarn publish dist/components --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-components-react'
run: yarn publish dist/react --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Remove files with forbidden extensions
run: node ./ci/clean-storybook-files.cjs
- name: 'Container: Login to GitHub Container Repository'
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin
- name: 'Container: Build image'
run: docker build -t $IMAGE_REPO:$VERSION -t $IMAGE_REPO:latest .
env:
DOCKER_BUILDKIT: 1
- name: 'Container: Publish image'
run: docker push $IMAGE_REPO:$VERSION
- name: 'Container: Publish image as latest'
run: docker push $IMAGE_REPO:latest

- name: Generate chromatic stories
run: yarn generate:chromatic-stories
- name: Create versioned storybook for chromatic
run: STORYBOOK_COMPONENTS_VERSION=$VERSION yarn build:storybook
env:
CHROMATIC: true
# Send storybook to chromatic. These snapshots should be accepted as new
# baseline in storybook.
- name: Publish to Chromatic
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_TOKEN }}
storybookBuildDir: dist/storybook
autoAcceptChanges: true
exitZeroOnChanges: true
zip: true

non-release:
needs: release-please
if: needs.release-please.outputs.releases_created != true
runs-on: ubuntu-latest
env:
IMAGE_REPO: ghcr.io/${{ github.repository_owner }}/server
VERSION: ${{ needs.release-please.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile --non-interactive

- name: Run build
run: STORYBOOK_COMPONENTS_VERSION="rev-$GITHUB_SHA" yarn build

- name: Remove files with forbidden extensions
run: node ./ci/clean-storybook-files.cjs
- name: 'Container: Login to GitHub Container Repository'
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin
- name: 'Container: Build image'
run: docker build -t $IMAGE_REPO:dev .
env:
DOCKER_BUILDKIT: 1
- name: 'Container: Publish image'
run: docker push $IMAGE_REPO:dev

- name: Generate chromatic stories
run: yarn generate:chromatic-stories
- name: Create versioned storybook for chromatic
run: STORYBOOK_COMPONENTS_VERSION="rev-$GITHUB_SHA" yarn build:storybook
env:
CHROMATIC: true
# Send storybook to chromatic. These snapshots should be accepted as new
# baseline in storybook.
- name: Publish to Chromatic
uses: chromaui/action@v1
with:
projectToken: ${{ secrets.CHROMATIC_TOKEN }}
storybookBuildDir: dist/storybook
autoAcceptChanges: true
exitZeroOnChanges: true
zip: true
103 changes: 0 additions & 103 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit c5793ea

Please sign in to comment.