-
Notifications
You must be signed in to change notification settings - Fork 13
155 lines (145 loc) · 6 KB
/
release-please.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Release Please
on:
push:
branches:
- '*.x'
- main
# Documentation:
# https://github.com/googleapis/release-please
# https://github.com/googleapis/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
env:
IMAGE_REPO_STORYBOOK: ghcr.io/${{ github.repository }}/storybook
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
target-branch: ${{ github.ref_name }}
- name: Release Info
run: echo "$RELEASE_OUTPUT"
env:
RELEASE_OUTPUT: ${{ toJSON(steps.release.outputs) }}
- name: 'Release: Determine version'
id: version
run: echo "version=$([[ "$VERSION" != "" ]] && echo "$VERSION" || echo "rev-$GITHUB_SHA")" >> $GITHUB_OUTPUT
env:
VERSION: ${{ steps.release.outputs.version }}
- name: Get token
id: get_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.MAINTENANCE_APP_ID }}
private_key: ${{ secrets.MAINTENANCE_APP_PEM }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.get_token.outputs.token }}
- uses: actions/setup-node@v4
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="${{ steps.version.outputs.version }}" yarn build
- name: Remove files with forbidden extensions
run: node ./scripts/clean-storybook-files.cjs
- name: 'Release: Determine npm tag'
if: ${{ steps.release.outputs.release_created }}
id: npm_tag
run: echo "npm_tag=$([[ "${{ steps.version.outputs.version }}" == *"-"* ]] && echo "next" || echo "latest")" >> $GITHUB_OUTPUT
- name: 'Release: Publish @sbb-esta/lyne-elements'
if: ${{ steps.release.outputs.release_created }}
run: yarn publish dist/elements --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-elements-experimental'
if: ${{ steps.release.outputs.release_created }}
run: yarn publish dist/elements-experimental --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-react'
if: ${{ steps.release.outputs.release_created }}
run: yarn publish dist/react --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-react-experimental'
if: ${{ steps.release.outputs.release_created }}
run: yarn publish dist/react-experimental --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Container: Login to GitHub Container Repository'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: 'Container: Build and publish release image'
if: ${{ steps.release.outputs.release_created }}
run: |
docker build --tag $IMAGE_REPO_STORYBOOK:$VERSION --tag $IMAGE_REPO_STORYBOOK:latest .
docker push $IMAGE_REPO_STORYBOOK:$VERSION
docker push $IMAGE_REPO_STORYBOOK:latest
env:
DOCKER_BUILDKIT: 1
VERSION: ${{ steps.release.outputs.version }}
- name: Build slim image with version
if: ${{ steps.release.outputs.release_created }}
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:${{ steps.release.outputs.version }}'
tag: '${{ steps.release.outputs.version }}-slim'
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Build slim image with latest
if: ${{ steps.release.outputs.release_created }}
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:latest'
tag: latest-slim
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
if: ${{ steps.release.outputs.release_created }}
run: |
docker push $IMAGE_REPO_STORYBOOK:$VERSION-slim
docker push $IMAGE_REPO_STORYBOOK:latest-slim
docker image list
env:
VERSION: ${{ steps.release.outputs.version }}
- name: 'Container: Build and publish dev image'
run: |
docker build --tag $IMAGE_REPO_STORYBOOK:dev .
docker push $IMAGE_REPO_STORYBOOK:dev
env:
DOCKER_BUILDKIT: 1
- name: Build slim image with dev
uses: kitabisa/docker-slim-action@v1
with:
target: '${{ env.IMAGE_REPO_STORYBOOK }}:dev'
tag: dev-slim
env:
DSLIM_PRESERVE_PATH: /usr/share/nginx/html
- name: Push slim image
run: |
docker push $IMAGE_REPO_STORYBOOK:dev-slim
docker image list
- name: Cherry-pick CHANGELOG.md into ${{ github.event.repository.default_branch }}
if: ${{ steps.release.outputs.release_created && github.ref_name != 'main' }}
run: |
git config user.email "[email protected]"
git config user.name "github-actions"
git checkout ${{ github.event.repository.default_branch }}
git show ${{ github.sha }} -- CHANGELOG.md | git apply -
git commit -a -m "chore: update changelog"
git push
- name: Update maintenance issue
if: ${{ steps.release.outputs.release_created && failure() }}
run: yarn ts-hooks scripts/update-maintenance-issue.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FAILED_RELEASE: ${{ steps.release.outputs.version }}