-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (80 loc) · 3.02 KB
/
Copy pathrelease.yml
File metadata and controls
92 lines (80 loc) · 3.02 KB
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
name: Release
on:
push:
branches:
- main
- '[0-9]+.[0-9]+*'
release:
types: [published]
permissions:
contents: write
jobs:
update-version:
runs-on: ubuntu-latest
# Only run on a release or pre-release
if: github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update package.json
uses: froozeify/gh-version-updater@v1.0.6
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "ci: Bump version to ${{ github.ref_name }}"
branch: main
file_pattern: package.json
- name: Upload package.json for build job
uses: actions/upload-artifact@v7
with:
name: package-json
path: package.json
build-and-push:
runs-on: ubuntu-latest
needs: update-version
if: success() || needs.update-version.result == 'skipped'
# This job depends on the update-version job.
# On a push to main, update-version is skipped, but this job will still run.
# On a release, this job waits for update-version to succeed.
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Download package.json
if: github.event_name == 'release'
uses: actions/download-artifact@v8
with:
name: package-json
path: .
- name: Login to Docker Hub
uses: docker/login-action@v4.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/narvik-front
tags: |
type=semver,pattern={{version}}
type=raw,value=dev,enable=${{ github.ref_name == github.event.repository.default_branch || github.event_name == 'release' }}
type=raw,value=latest,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
type=semver,pattern={{major}}.{{minor}},enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
type=semver,pattern={{major}},enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
type=ref,event=branch,pattern=^([0-9]+\.[0-9]+.*)$,group=1,prefix=dev-,enable=${{ github.ref_name != github.event.repository.default_branch }}
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
sbom: true
provenance: mode=max
labels: |
${{ steps.meta.outputs.labels }}
org.opencontainers.image.vendor=Benoit VIGNAL
org.opencontainers.image.url=https://about.narvik.app