-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (158 loc) · 6.01 KB
/
deploy_public.yaml
File metadata and controls
181 lines (158 loc) · 6.01 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
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
name: Deploy Public
env:
REPO_NAME: smsfusion-python
REPO_NAME_SHORT: smsfusion
SRC_ROOT_PATH: "./src/smsfusion"
on:
workflow_dispatch:
inputs:
version_number:
description: Release version number [MAJOR.MINOR.PATCH] to deploy. Use "$latest" to automatically choose the latest release.
required: true
type: string
default: "$latest"
pipeline:
description: Choose deploy pipeline.
required: true
default: production
type: choice
options:
- production
- test
doc_latest:
description: Deploy documentation as latest?
default: true
required: true
type: boolean
jobs:
build:
runs-on: ubuntu-latest
outputs:
version_number: ${{ steps.version_number.outputs.VERSION_NUMBER }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install hatch
- name: Get new version number from input
id: version_number
run: |
if [ "${{ inputs.version_number }}" = "$latest" ]
then
version="$(gh release view --json tagName --jq .tagName)"
version=${version#v}
else
version="${{ inputs.version_number }}"
fi
echo "VERSION_NUMBER=$version" | tee $GITHUB_ENV $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update package version number
run: hatch version $VERSION_NUMBER
- name : Inject release notes to documentation
run: |
gh api "https://api.github.com/repos/{owner}/{repo}/releases" --template "
{{- range . -}}
{{ if and (le .tag_name \"v$VERSION_NUMBER\") (eq .draft false) (eq .prerelease false) }}
# [{{ .name }}]({{ .html_url }})
{{ .body }}
{{ end }}
{{- end -}}
" > docs/release_notes/generated.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package
run: hatch build -t wheel
- name: Build documentation
run: hatch run docs:build
- name: Stash build artifacts
uses: actions/upload-artifact@v4
with:
name: build_artifacts
path: |
./dist/*.whl
./build/html
retention-days: 1
deploy-test:
if: ${{ inputs.pipeline == 'test' }}
runs-on: ubuntu-latest
needs: build
env:
VERSION_NUMBER: ${{ needs.build.outputs.version_number }}
name: pypi
url: https://pypi.org/p/<your-pypi-project-name>
permissions:
id-token: write
steps:
- name: Clean up artifacts directory
shell: pwsh
run: Get-ChildItem . | Remove-Item -Recurse -Force
- name: Fetch build artifacts
uses: actions/download-artifact@v4
with:
name: build_artifacts
- name: Publish package to TestPyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Upload documentation to TEST blob storage
uses: azure/CLI@v2
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.FOURINSIGHTTEST_DOC_BLOB_CONNSTR }}
with:
azcliversion: 2.76.0 # Can be removed when this issue is fixed. https://github.com/Azure/azure-cli/issues/32039
inlineScript: |
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "$REPO_NAME_SHORT/python/docs/$VERSION_NUMBER"
- name: Upload documentation to TEST blob storage as latest
if: ${{ inputs.doc_latest }}
uses: azure/CLI@v2
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.FOURINSIGHTTEST_DOC_BLOB_CONNSTR }}
with:
azcliversion: 2.76.0 # Can be removed when this issue is fixed. https://github.com/Azure/azure-cli/issues/32039
inlineScript: |
az storage blob delete-batch -s "\$web" --pattern "$REPO_NAME_SHORT/python/docs/latest/*"
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "$REPO_NAME_SHORT/python/docs/latest"
deploy-prod:
if: ${{ inputs.pipeline == 'production' }}
runs-on: ubuntu-latest
needs: build
env:
VERSION_NUMBER: ${{ needs.build.outputs.version_number }}
name: pypi
url: https://pypi.org/p/<your-pypi-project-name>
permissions:
id-token: write
steps:
- name: Clean up artifacts directory
shell: pwsh
run: Get-ChildItem . | Remove-Item -Recurse -Force
- name: Fetch build artifacts
uses: actions/download-artifact@v4
with:
name: build_artifacts
- name: Publish package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
- name: Upload documentation to PROD blob storage
uses: azure/CLI@v2
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.FOURINSIGHTPROD_DOC_BLOB_CONNSTR }}
with:
azcliversion: 2.76.0 # Can be removed when this issue is fixed. https://github.com/Azure/azure-cli/issues/32039
inlineScript: |
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "$REPO_NAME_SHORT/python/docs/$VERSION_NUMBER"
- name: Upload documentation to PROD blob storage as latest
if: ${{ inputs.doc_latest }}
uses: azure/CLI@v2
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.FOURINSIGHTPROD_DOC_BLOB_CONNSTR }}
with:
azcliversion: 2.76.0 # Can be removed when this issue is fixed. https://github.com/Azure/azure-cli/issues/32039
inlineScript: |
az storage blob delete-batch -s "\$web" --pattern "$REPO_NAME_SHORT/python/docs/latest/*"
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "$REPO_NAME_SHORT/python/docs/latest"