-
Notifications
You must be signed in to change notification settings - Fork 43
73 lines (64 loc) · 2.48 KB
/
release.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
name: Release
on:
push:
branches:
- main
- next
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
runs-on: ubuntu-latest
permissions:
# See provenance docs: https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
id-token: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_GH_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install dependencies and build TS
run: npm ci && npm run build
- name: Install semantic-release and friends
run: npm i --no-save semantic-release@21 @semantic-release/changelog@6 @semantic-release/exec@6 @semantic-release/git@10
# We do a dry run here to analyze the commits and grab the next version
# for usage in the Docker metadata action
- name: Dry run of semantic-release workflow
run: npx semantic-release --dry-run
id: release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# For every release we add 2-3 tags to the docker build:
# 1. A semver tag (e.g., 8.0.0, 8.0.0-next.0)
# 2. A branch tag (e.g., next, main)
# 3. A `latest` tag (only on the main branch)
tags: |
type=semver,pattern={{version}},value=${{ steps.release.outputs.nextVersion }}
type=ref,event=branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Run semantic-release workflow
env:
GH_TOKEN: ${{ secrets.RELEASE_GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# See provenance docs: https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions
NPM_CONFIG_PROVENANCE: 'true'
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release