-
-
Notifications
You must be signed in to change notification settings - Fork 2
213 lines (205 loc) · 6.77 KB
/
Continuous-Integration.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
name: Continuous-Integration
on:
push:
tags:
- '*'
branches:
- main
pull_request: { }
jobs:
Lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: "Install the toolchain"
uses: moonrepo/setup-rust@v0
with:
profile: minimal
components: clippy
- name: "Check with clippy"
run: |
cargo clippy -- -D warnings
Test:
name: Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: "Install dependencies"
run: |
sudo add-apt-repository ppa:inkscape.dev/stable -y
sudo apt update
sudo apt-get install pkg-config libssl-dev openjdk-11-jre graphviz inkscape
inkscape --version
inkscape --help
shell: bash
- name: "Install the toolchain"
uses: moonrepo/setup-rust@v0
with:
profile: minimal
- name: "Perform the tests"
run: |
cargo test
Binary:
name: Binary
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- architecture: aarch64
system: linux
target: aarch64-unknown-linux-gnu
- architecture: x86_64
system: linux
target: x86_64-unknown-linux-gnu
- architecture: powerpc64le
system: linux
target: powerpc64le-unknown-linux-gnu
- architecture: s390x
system: linux
target: s390x-unknown-linux-gnu
steps:
- uses: actions/checkout@v3
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Install the dependencies"
run: |
sudo apt-get install pkg-config libssl-dev
sudo apt-get install pkg-config libssl-dev build-essential dpkg libc-bin liblzma-dev
shell: bash
- name: "Install the toolchain"
uses: moonrepo/setup-rust@v0
with:
profile: minimal
bins: cargo-deb
- name: "Install the target"
run: |
rustup target add ${{ matrix.target }}
- name: "Install cross"
run: |
cargo binstall --no-confirm cross
- name: "Build the binary"
run: |
cross build --release --target=${{ matrix.target }} --features vendored-openssl
- name: "Archive the binary"
run: |
tar -C target/${{ matrix.target }}/release/ -czf ${{ matrix.system }}_${{ matrix.architecture }}_plantuml-generator.tar.gz plantuml-generator
- name: "Upload the binary"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.system }}_${{ matrix.architecture }}_plantuml-generator
path: ${{ matrix.system }}_${{ matrix.architecture }}_plantuml-generator.tar.gz
overwrite: true
DebianPackage:
name: Debian Package
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- architecture: x86_64
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v3
- name: "Install the dependencies"
run: |
sudo apt-get install pkg-config libssl-dev build-essential dpkg libc-bin liblzma-dev
shell: bash
- name: "Install the toolchain"
uses: moonrepo/setup-rust@v0
with:
profile: minimal
bins: cargo-deb
- name: "Install the target"
run: |
rustup target add ${{ matrix.target }}
- name: "Build the deb package"
run: |
cargo deb --target=${{ matrix.target }} --profile release -- --features vendored-openssl
- name: "Upload the deb package"
uses: actions/upload-artifact@v4
with:
name: debian_${{ matrix.architecture }}_plantuml-generator
path: target/${{ matrix.target }}/debian/*.deb
overwrite: true
DockerImage:
name: Docker Image
runs-on: ubuntu-22.04
needs: [ Lint, Test ]
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v3
- name: "Set up QEMU"
uses: docker/setup-qemu-action@v3
- name: "Login to Docker Hub"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
with:
install: true
- name: "Inject slug/short variables"
uses: rlespinasse/[email protected]
- name: "Build and push branches"
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64
tags: |
thibaultmorin/plantuml-generator:${{ env.GITHUB_REF_SLUG }}
build-args: |
git_sha=${{ github.sha }}
- name: "Process version of the tag"
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: version
uses: ncipollo/semantic-version-action@v1
- name: "Build and push tags"
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64
tags: |
thibaultmorin/plantuml-generator:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}
thibaultmorin/plantuml-generator:${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}
thibaultmorin/plantuml-generator:${{ steps.version.outputs.major }}
build-args: |
git_sha=${{ github.sha }}
GithubRelease:
name: Github Release
runs-on: ubuntu-22.04
needs: [ Lint, Test, Binary, DebianPackage ]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- uses: actions/checkout@v3
- name: "Download all artifacts"
uses: actions/download-artifact@v3
with:
path: artifacts
- name: "List artifacts"
run: |
ls -R
working-directory: artifacts
- name: "Create the changelog"
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
with:
ignorePreReleases: true
commitMode: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Create the release"
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "artifacts/**/*.tar.gz,artifacts/**/*.deb"
omitName: true
draft: false
body: ${{steps.build_changelog.outputs.changelog}}
token: ${{ secrets.GITHUB_TOKEN }}