-
Notifications
You must be signed in to change notification settings - Fork 16
178 lines (171 loc) · 6.55 KB
/
ci.yaml
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
name: Main CI
on:
push:
branches: ['main', 'next']
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: ubuntu-latest
if: github.event.head_commit.author.name != 'github-actions[bot]'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn && yarn build
- uses: actions/upload-artifact@v4
with:
name: pogues
path: dist
- run: cd next && yarn && yarn build
- uses: actions/upload-artifact@v4
with:
name: pogues-next
path: next/dist
check_if_version_upgraded:
needs: build
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
outputs:
version: ${{ steps.version.outputs.prop }}
is_version_changed: ${{ steps.check.outputs.exists == 'false' }}
is_pre_release: ${{ contains(steps.version.outputs.prop, '-rc' ) }}
next_version: ${{ steps.next_version.outputs.prop }}
next_is_version_changed: ${{ steps.next_check.outputs.exists == 'false' }}
next_is_pre_release: ${{ contains(steps.next_check.outputs.prop, '-rc' ) }}
steps:
- uses: actions/checkout@v4
- id: version
uses: notiz-dev/github-action-json-property@release
with:
path: 'package.json'
prop_path: 'version'
## we check if repo contains already this tag, if not version, has changed
- uses: mukunku/[email protected]
id: check
with:
tag: ${{ steps.version.outputs.prop }}
- uses: actions/checkout@v4
- id: next_version
uses: notiz-dev/github-action-json-property@release
with:
path: 'next/package.json'
prop_path: 'version'
## we check if repo contains already this tag, if not version, has changed
- uses: mukunku/[email protected]
id: next_check
with:
tag: ${{ steps.next_version.outputs.prop }}
docker_pogues:
needs: check_if_version_upgraded
if: |
(github.event_name == 'push' || needs.check_if_version_upgraded.outputs.is_pre_release == 'true') &&
needs.check_if_version_upgraded.outputs.is_version_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: pogues
path: dist
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: '.'
push: true
tags: |
inseefr/pogues:latest,
inseefr/pogues:${{ needs.check_if_version_upgraded.outputs.version }}
docker_pogues_next:
needs: check_if_version_upgraded
if: |
(github.event_name == 'push' || needs.check_if_version_upgraded.outputs.next_is_pre_release == 'true') &&
needs.check_if_version_upgraded.outputs.next_is_version_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
name: pogues-next
path: next/dist
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: './next'
push: true
tags: |
inseefr/pogues:latest,
inseefr/pogues:${{ needs.check_if_version_upgraded.outputs.next_version }}
release:
runs-on: ubuntu-latest
needs: check_if_version_upgraded
# We create release only if the version in the package.json have been upgraded and this CI is running against the main branch.
# We allow branches with a PR open on main to publish pre-release (x.y.z-rc.u) but not actual releases.
if: |
(github.event_name == 'push' || needs.check_if_version_upgraded.outputs.is_pre_release == 'true') &&
needs.check_if_version_upgraded.outputs.is_version_changed == 'true'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/download-artifact@v4
with:
name: pogues
path: dist
- name: Zip bundle
run: cd dist && zip -r ../pogues.zip ./*
- uses: softprops/action-gh-release@v2
with:
name: Release ${{ needs.check_if_version_upgraded.outputs.version }}
tag_name: ${{ needs.check_if_version_upgraded.outputs.version }}
target_commitish: ${{ github.head_ref || github.ref }}
generate_release_notes: true
draft: false
prerelease: ${{ needs.check_if_version_upgraded.outputs.is_pre_release == 'true' }}
files: ./pogues.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release_next:
runs-on: ubuntu-latest
needs: check_if_version_upgraded
# We create release only if the version in the package.json have been upgraded and this CI is running against the main branch.
# We allow branches with a PR open on main to publish pre-release (x.y.z-rc.u) but not actual releases.
if: |
(github.event_name == 'push' || needs.check_if_version_upgraded.outputs.next_is_pre_release == 'true') &&
needs.check_if_version_upgraded.outputs.next_is_version_changed == 'true'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- uses: actions/download-artifact@v4
with:
name: pogues-next
path: next/dist
- name: Zip bundle
run: cd next/dist && zip -r ../pogues.zip ./*
- uses: softprops/action-gh-release@v2
with:
name: Release ${{ needs.check_if_version_upgraded.outputs.next_version }}
tag_name: ${{ needs.check_if_version_upgraded.outputs.next_version }}
target_commitish: ${{ github.head_ref || github.ref }}
generate_release_notes: true
draft: false
prerelease: ${{ needs.check_if_version_upgraded.outputs.next_is_pre_release == 'true' }}
files: ./next/pogues.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}