-
Notifications
You must be signed in to change notification settings - Fork 2
115 lines (98 loc) · 4.41 KB
/
Copy pathworkflow.yml
File metadata and controls
115 lines (98 loc) · 4.41 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Workflow (webitel-engine)
run-name: "webitel-engine@${{ github.ref_name }}#${{ github.run_number }} - ${{ github.event.head_commit.message }}"
on:
push:
branches: [ main, "v[0-9]+.[0-9]+" ]
permissions: { contents: read }
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: Prepare
uses: webitel/reusable-workflows/.github/workflows/golang-prepare.yml@v2
permissions:
contents: read
pull-requests: read
id-token: write
with:
development-branch: ${{ github.event.repository.default_branch }}
triggered-branch: ${{ github.ref_name }}
arch: ${{ vars.BUILD_ARCH }}
codename: ${{ vars.DEB_CODENAME }}
checks:
name: Checks
needs: [ prepare ]
uses: webitel/reusable-workflows/.github/workflows/golang-checks.yml@v2
permissions:
contents: read
actions: read
security-events: write
with:
changes: ${{ needs.prepare.outputs.changes }}
compile:
name: Build
needs: [ prepare ]
strategy:
matrix:
arch: ${{ fromJSON(needs.prepare.outputs.arch-matrix) }}
uses: webitel/reusable-workflows/.github/workflows/golang-build.yml@v2
with:
arch: ${{ matrix.arch }}
binary-name: webitel-engine
ldflags: >
-s -w
-X github.com/webitel/engine/model.BuildNumber=${{ github.run_number }}
-X github.com/webitel/engine/model.CurrentVersion=${{ format('{0}{1}', needs.prepare.outputs.version, (github.event.repository.default_branch == github.ref_name || github.event.pull_request.number) && '-dev' || '') }}
version: ${{ needs.prepare.outputs.version }}
version-build: ${{ github.run_number }}
prerelease: ${{ github.event.repository.default_branch == github.ref_name && 'dev' || '' }}
package-name: webitel-engine
package-description: ${{ github.event.repository.description }}
package-contents: |
src=deploy/systemd/webitel-engine.service dst=/etc/systemd/system/webitel-engine.service type=config
src=deploy/debian/postinst.d/ dst=/usr/lib/webitel/webitel-engine/deb/postinst.d/
src=.env.example dst=/etc/default/webitel-engine type=config mode=0640
package-depends:
scripts: |
postinstall: deploy/debian/postinst.sh
preremove: deploy/debian/prerm.sh
postremove: deploy/debian/postrm.sh
deploy:
name: Deploy
if: github.event.repository.private == false
needs: [ prepare, compile ]
uses: webitel/reusable-workflows/.github/workflows/_deploy.yml@v2
secrets: inherit
with:
repository-environment: ${{ github.event.repository.default_branch == github.ref_name && 'acceptance' || format('{0}-releases', needs.prepare.outputs.version) }}
deb-package-pattern: "webitel-engine*.deb"
publish:
name: Publish
needs: [ prepare, compile, deploy ]
if: always() && !cancelled() && github.event.repository.private == false && needs.compile.result == 'success' && (needs.deploy.result == 'success' || needs.deploy.result == 'skipped')
strategy:
matrix:
arch: ${{ fromJSON(needs.prepare.outputs.arch-matrix) }}
codename: ${{ fromJSON(needs.prepare.outputs.codename-matrix) }}
uses: webitel/reusable-workflows/.github/workflows/_publish-deb.yml@v2
secrets: inherit
with:
arch: ${{ matrix.arch }}
repository-environment: ${{ github.event.repository.default_branch == github.ref_name && 'acceptance' || format('{0}-releases', needs.prepare.outputs.version) }}
deb-package-pattern: "webitel-engine*.deb"
deb-component: ${{ github.event.repository.default_branch == github.ref_name && 'dev' || format('{0}-releases', needs.prepare.outputs.version) }}
deb-codename: ${{ matrix.codename }}
deb-s3-bucket-name: ${{ vars.DEB_S3_BUCKET_NAME }}
deb-s3-bucket-region: ${{ vars.DEB_S3_DEFAULT_REGION }}
deb-s3-endpoint: ${{ vars.DEB_S3_ENDPOINT }}
deb-s3-force-path-style: ${{ vars.DEB_S3_FORCE_PATH_STYLE == 'true' }}
release:
name: Release
needs: [ prepare, publish ]
if: github.event.repository.default_branch != github.ref_name && needs.publish.result == 'success'
uses: webitel/reusable-workflows/.github/workflows/_release.yml@v2
permissions: { contents: write }
with:
tag: ${{ format('{0}-{1}', needs.prepare.outputs.version, github.run_number) }}
tag-target-commitish: ${{ github.sha }}