-
-
Notifications
You must be signed in to change notification settings - Fork 12
95 lines (82 loc) · 2.59 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
90
91
92
93
94
95
name: Create Release
on:
workflow_dispatch
jobs:
create-tag:
name: "Create tag from package.json"
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create-tag.outputs.version }}
tag: ${{ steps.create-tag.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Git tag
id: create-tag
run: |
version="$(jq -r '.version' package.json)"
tag="v$version"
git tag $tag
git push origin $tag
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
github-release:
needs:
- create-tag
name: "Create GitHub release"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create changelog
id: changelog
uses: loopwerk/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
config_file: .github/tag-changelog.cjs
- name: Create release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{needs.create-tag.outputs.tag}}
name: Release ${{needs.create-tag.outputs.tag}}
body: ${{ steps.changelog.outputs.changes }}
release-docker:
needs:
- create-tag
name: "Build & Release docker image (tag)"
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest
type=semver,pattern={{version}},value=${{needs.create-tag.outputs.version}}
type=semver,pattern={{major}}.{{minor}},value=${{needs.create-tag.outputs.version}}
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}