forked from SonarSource/sonarcloud-github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (78 loc) · 2.73 KB
/
ci.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
---
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v4
with:
push: false
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
release-please:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }} # e.g. v1.0.0
version: ${{ steps.release-please.outputs.version }} # e.g. 1.0.0
steps:
- uses: google-github-actions/release-please-action@v3
id: release-please
with:
command: manifest
config-file: .github/release-please-config.json
manifest-file: .github/.release-please-manifest.json
- name: Create/update MAJOR tag
if: ${{ steps.release-please.outputs.release_created }}
uses: richardsimko/update-tag@v1
with:
tag_name: v${{ steps.release-please.outputs.major }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create/update MAJOR.MINOR tag
if: ${{ steps.release-please.outputs.release_created }}
uses: richardsimko/update-tag@v1
with:
tag_name: v${{ steps.release-please.outputs.major }}.${{ steps.release-please.outputs.minor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-latest:
runs-on: ubuntu-latest
needs: [build]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
steps:
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
release:
runs-on: ubuntu-latest
needs: [release-please, build]
if: needs.release-please.outputs.release_created
steps:
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ needs.release-please.outputs.version }}
ghcr.io/${{ github.repository }}:stable
cache-from: type=gha
cache-to: type=gha,mode=max