-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (75 loc) · 2.76 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: release
on:
workflow_dispatch:
inputs:
version:
description: |
New version for the release
If the version is in format <major>.<minor>.<patch> a new release is emitted.
Otherwise for other format ( for example <major>.<minor>.<patch>-beta.1 ), a prerelease is emitted.
default: "1.0.0"
required: true
type: string
description:
description: "Version description"
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Bump version
run: bun run scripts/bump-version.ts ${{ github.event.inputs.version }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish the docker image
uses: docker/build-push-action@v4
id: docker-build
with:
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:${{ github.event.inputs.version }}
- name: Update action.yml to point to the newly created docker image
run: |
NEW_IMAGE="ghcr.io/${{ github.repository }}@${{ steps.docker-build.outputs.digest }}"
sed -i 's|image: "docker://.*"|image: "docker://'$NEW_IMAGE'"|' action.yml
- name: Push new build, tag version and push
id: push-tags
run: |
VERSION=${{ github.event.inputs.version }}
git config --global user.email "[email protected]"
git config --global user.name "CherninLab release bot"
git add action.yml
git add package.json
git commit -m "📦 $VERSION"
git tag v$VERSION
git push origin main --tags
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
git tag v$( echo $VERSION | cut -d. -f 1-1 )
git tag v$( echo $VERSION | cut -d. -f 1-2 )
git push origin --tags --force
echo "prerelease=false" >> $GITHUB_OUTPUT
else
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
- uses: ncipollo/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ github.event.inputs.version }}
body: ${{ github.event.inputs.description }}
prerelease: ${{ steps.push-tags.outputs.prerelease }}