-
Notifications
You must be signed in to change notification settings - Fork 13
185 lines (183 loc) · 6.17 KB
/
publish.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
name: Publish Connect Command Line Client
on:
push:
tags:
- '*'
jobs:
linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Linting
run: |
poetry run flake8
- name: Testing
run: |
poetry run pytest
- name: Checkout latest reports repository
run: |
poetry run python resources/get_latest_reports.py
- name: Extract tag name
uses: actions/github-script@v6
id: tag
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\//, '')
- name: Build and publish to pypi.org
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
poetry version ${{ steps.tag.outputs.result }}
poetry build
if [ "$(curl -s -o /dev/null -w '%{http_code}' https://pypi.org/pypi/connect-cli/${{ steps.tag.outputs.result }}/json)" = "404" ]; then poetry publish -u $TWINE_USERNAME -p $TWINE_PASSWORD; fi
- name: Set Connect and CLI major versions
id: cnctver
run: |
echo connect_major="$(curl -sI https://api.connect.cloudblue.com/public/v1|grep -Fi 'connect-version' | tr -d '\r' | sed -En 's/^Connect-Version: (.*)/\1/p'|cut -f1 -d'.')" >> $GITHUB_OUTPUT
echo cli_major="$(echo ${{ steps.tag.outputs.result }}|cut -f1 -d '.')" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: amd64,arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: cloudblueconnect/connect-cli
tags: |
type=semver,pattern={{major}}.{{minor}},value=${{ steps.tag.outputs.result }}.0
type=semver,pattern={{major}},value=${{ steps.tag.outputs.result }}.0
type=raw,value=latest,enable=${{ steps.cnctver.outputs.connect_major == steps.cnctver.outputs.cli_major }}
flavor: |
latest=false
- name: Build and push docker image
id: docker_build
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
push: true
context: .
file: resources/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
- name: Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry pynsist wheel
poetry install
- name: Checkout latest reports repository
run: |
poetry run python resources/get_latest_reports.py
- name: Extract tag name
uses: actions/github-script@v3
id: tag
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\//, '')
- name: Generate connect-cli wheel
run: |
poetry version ${{ steps.tag.outputs.result }}
poetry build
cp dist/*.whl resources/.
- name: Generate pynsist config file
run: |
poetry export --format constraints.txt --without-hashes --output resources/requirements.txt
poetry run python resources/generate_pynsist_config.py
cat resources/ccli.cfg
- name: Build windows installer
run: |
pynsist resources/ccli.cfg
- name: Package windows distro
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS_NAME: windows
CPU_ARCH: amd64
PKG_TAG: ${{ steps.tag.outputs.result }}
run: |
& { compress-archive -path '.\resources\build\nsis\connect-cli_${{ steps.tag.outputs.result }}_setup.exe' -destinationpath '.\connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip' }
- name: Upload distro package to artifacts
uses: actions/upload-artifact@v3
with:
name: windows_distro
path: connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip
retention-days: 5
release:
runs-on: ubuntu-latest
needs: [linux, windows]
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Extract tag name
uses: actions/github-script@v6
id: tag
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\//, '')
- name: Create release
uses: ncipollo/release-action@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
allowUpdates: true
tag: ${{ steps.tag.outputs.result }}
name: Release ${{ steps.tag.outputs.result }}
draft: false
prerelease: false
- name: Download windows artifact
uses: actions/download-artifact@v3
with:
name: windows_distro
path: ./
- name: Attach windows distro to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip
asset_name: connect-cli_${{ steps.tag.outputs.result }}_windows_amd64.zip
asset_content_type: application/zip