forked from avisi-cloud/structurizr-site-generatr
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (163 loc) · 5.94 KB
/
release.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
name: release
on:
push:
tags:
- '*'
env:
IMAGE_NAME: ${{ github.event.repository.name }}
jobs:
build-gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 19
- name: Setup Gradle
uses: gradle/[email protected]
- name: Execute Gradle build
run: ./gradlew -PprojectVersion=${{ github.ref_name }} test assemble installDist
- name: Archive binaries
uses: actions/upload-artifact@v3
with:
name: binaries
path: build/install
retention-days: 1
- name: Archive distribution
uses: actions/upload-artifact@v3
with:
name: distribution
path: build/distributions
retention-days: 1
build-push-docker:
runs-on: ubuntu-latest
needs: build-gradle
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Set up cosign
uses: sigstore/cosign-installer@main
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries
path: build/install
- name: Download distribution
uses: actions/download-artifact@v3
with:
name: distribution
path: build/distributions
- name: Build and publish container image
uses: docker/build-push-action@v4
id: build_push
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64/v8
tags: |
ghcr.io/avisi-cloud/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
ghcr.io/avisi-cloud/${{ env.IMAGE_NAME }}:latest
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.ref_name }}
- name: sign container image
run: |
cosign sign --yes --key env://COSIGN_KEY ghcr.io/avisi-cloud/${{ env.IMAGE_NAME }}:${{ github.ref_name }}@${{ steps.build_push.outputs.digest }}
shell: bash
env:
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
- name: Check images
run: |
docker buildx imagetools inspect ghcr.io/avisi-cloud/${IMAGE_NAME}:${{ github.ref_name }}
docker pull ghcr.io/avisi-cloud/${IMAGE_NAME}:${{ github.ref_name }}
cosign verify --key cosign.pub ghcr.io/avisi-cloud/${IMAGE_NAME}:${{ github.ref_name }}
- uses: anchore/sbom-action@v0
with:
image: ghcr.io/avisi-cloud/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
create-draft-release:
runs-on: ubuntu-latest
needs: build-gradle
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download distribution
uses: actions/download-artifact@v3
with:
name: distribution
path: build/distributions
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: v${{ github.ref_name }}
draft: true
prerelease: false
- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/distributions/structurizr-site-generatr-${{ github.ref_name }}.tar.gz
asset_name: structurizr-site-generatr-${{ github.ref_name }}.tar.gz
asset_content_type: application/x-tar
- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/distributions/structurizr-site-generatr-${{ github.ref_name }}.zip
asset_name: structurizr-site-generatr-${{ github.ref_name }}.zip
asset_content_type: application/zip
publish-example-site:
runs-on: ubuntu-latest
needs: build-gradle
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 19
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries
path: build/install
- name: Set up environment
run: |
sudo apt-get install -y graphviz
chmod +x build/install/structurizr-site-generatr/bin/structurizr-site-generatr
- name: Generate example site
run: >
build/install/structurizr-site-generatr/bin/structurizr-site-generatr generate-site
--git-url https://github.com/avisi-cloud/structurizr-site-generatr.git
--workspace-file docs/example/workspace.dsl
--assets-dir docs/example/assets
--branches main
--default-branch main
--version ${{ github.ref_name }}
- name: Publish example site
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/site