-
Notifications
You must be signed in to change notification settings - Fork 2
150 lines (144 loc) · 4.81 KB
/
ci-build.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Build
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
analyze-commits:
runs-on: ubuntu-latest
steps:
-
name: Echo DOCKER_IMAGE_REPOSITORY
run: "echo DOCKER_IMAGE_REPOSITORY: '${{ vars.DOCKER_IMAGE_REPOSITORY }}'"
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
-
name: "🔧 setup node"
uses: actions/setup-node@v2.1.5
with:
node-version: 20.x
-
name: "Install plugin for semantic-release"
run: npm install @google/semantic-release-replace-plugin -D
-
name: Install dependencies
run: yarn global add semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/commit-analyzer@10.0.1 conventional-changelog-conventionalcommits@6.1.0
-
name: Get next version
id: next-version
run: semantic-release --dryRun
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
release-tag: ${{ steps.next-version.outputs.release-tag }}
release-version: ${{ steps.next-version.outputs.release-version }}
docker:
uses: ./.github/workflows/docker-build-and-push-workflow.yml
needs: analyze-commits
secrets: inherit
with:
version: ${{ needs.analyze-commits.outputs.release-version }}
publish: >-
${{ (startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main') &&
github.event_name == 'push' }}
docker-image-repo: ${{ vars.DOCKER_IMAGE_REPOSITORY }}
upload-sarif-to-security: >-
${{ (startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main') &&
github.event_name == 'push' }}
release:
runs-on: ubuntu-latest
needs:
- docker
- analyze-commits
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
-
name: Update BuildInfo.properties if there is a version
run: /bin/bash .github/workflows/writeBuildInfo.sh ${{ needs.analyze-commits.outputs.release-version }}
-
name: Make JAR of configuration
run: jar cvf /tmp/MijnZaakNotificaties.jar -C src/main/configurations LopendeZaken
-
name: "🔧 setup node"
uses: actions/setup-node@v2.1.5
with:
node-version: 20.x
-
name: Install dependencies
run: yarn global add semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github @semantic-release/exec @semantic-release/release-notes-generator @semantic-release/commit-analyzer@10.0.1 conventional-changelog-conventionalcommits@6.1.0
-
name: Semantic Release
run: "semantic-release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Pull commit that holds the newly created tag - if applicable
run: git pull origin main
if: github.ref == 'refs/heads/main'
-
name: Release on GitHub
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.analyze-commits.outputs.release-version }}
files: /tmp/MijnZaakNotificaties.jar
if: >-
(startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main') &&
github.event_name == 'push' &&
needs.analyze-commits.outputs.release-version != '' &&
needs.analyze-commits.outputs.release-version != null
publish-docker:
runs-on: ubuntu-latest
needs:
- release
- analyze-commits
if: >-
(startsWith(github.ref, 'refs/tags/') ||
github.ref == 'refs/heads/main') &&
github.event_name == 'push' &&
needs.analyze-commits.outputs.release-version != '' &&
needs.analyze-commits.outputs.release-version != null
steps:
-
name: Show release version
run: echo "Pushing docker image for version ${{ needs.analyze-commits.outputs.release-version }}"
-
name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
-
name: "Download Docker artifact"
uses: actions/download-artifact@v2
with:
name: docker
path: /tmp
-
name: "Load Docker artifact"
run: |
docker load --input /tmp/docker.tar
docker image ls -a
-
name: Login to Container Registry
uses: docker/login-action@v2
if: github.event_name == 'push'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Push Docker image
run: docker push ${{ vars.DOCKER_IMAGE_REPOSITORY }} --all-tags