-
-
Notifications
You must be signed in to change notification settings - Fork 7
105 lines (96 loc) · 3.41 KB
/
build-and-release.yaml
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
name: Semantic release
on:
workflow_dispatch:
push:
paths:
- "src/**"
- "dockerfile"
- ".releaserc"
- "package.json"
- "README.md"
- "dockerfile"
branches:
- "main"
- "dev"
env:
GH_TOKEN: ${{ secrets.AUTH_GH }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
NEW_RELEASE_PUBLISHED: false
HUSKY: 0
jobs:
build:
runs-on: ubuntu-latest
outputs:
NEW_RELEASE_PUBLISHED: ${{ steps.semantic-release.outputs.new_release_published }}
NEXT_VERSION: ${{ steps.semantic-release.outputs.version }}
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- id: semantic-release
run: npm run semantic-release:ci
docker:
needs: build
runs-on: ubuntu-latest
if: needs.build.outputs.NEW_RELEASE_PUBLISHED
steps:
- env:
NEW_RELEASE_PUBLISHED: ${{ needs.build.outputs.NEW_RELEASE_PUBLISHED }}
NEXT_VERSION: ${{ needs.build.outputs.NEXT_VERSION }}
run: echo "Creating docker release for version $NEXT_VERSION"
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v4.5.0
with:
cosign-release: "v1.13.1"
- name: Setup Docker buildx
uses: docker/setup-buildx-action@0f069ddc17b8eb78586b08a7fe335fd54649e2d3
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@06895751d15a223ec091bea144ad5c7f50d228d0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.GH_TOKEN }}
- name: Echo Version
run: |
echo "Docker: $NEXT_VERSION"
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=latest,enable={{ is_default_branch }}
type=raw,value=${{ needs.build.outputs.NEXT_VERSION }}
type=semver,pattern={{version}},value=${{ needs.build.outputs.NEXT_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.build.outputs.NEXT_VERSION }}
type=semver,pattern={{major}},value=${{ needs.build.outputs.NEXT_VERSION }}
type=ref,event=branch
#type=sha
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@5e99dacf67635c4f273e532b9266ddb609b3025a
with:
context: .
build-args: |
DOCUDIGGER_VERSION=${{ needs.build.outputs.NEXT_VERSION }}
platforms: linux/amd64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max