forked from Deltares/hydromt
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (124 loc) · 4.26 KB
/
create-release-artifacts.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
name: Create release artifacts
on:
workflow_dispatch:
# running this when PR opens we'll do in prep-release manually, see that file for more details
push:
branches:
- 'release/**'
workflow_run:
workflows: [Create a new release]
types:
- completed
jobs:
pypi:
runs-on: ubuntu-latest
outputs:
url: ${{ steps.upload-pypi-release-artifacts.outputs.artifact-url }}
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.11'
- name: generate env
run: |
pip install tomli flit twine
- name: Build artifacts
run: |
git clean -xdf
git restore -SW .
flit build
python -m twine check dist/*
- name: Publish package to TestPyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TEST_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true
- uses: actions/upload-artifact@v4
id: upload-pypi-release-artifacts
with:
name: pypi-release-artifacts
path: dist
docs:
runs-on: ubuntu-latest
outputs:
url: ${{ steps.upload-docs-release-artifacts.outputs.artifact-url }}
if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: prefix-dev/[email protected]
with:
pixi-version: "v0.21.1"
environments: full-py311
- name: Generate docs
run: |
pixi run -e full-py311 install
pixi run --locked -e full-py311 doc
- uses: actions/upload-artifact@v4
id: upload-docs-release-artifacts
with:
name: docs-release-artifacts
path: docs/_build
# docker:
# runs-on: ubuntu-latest
# outputs:
# url: ${{ steps.upload-docker-release-artifacts.outputs.artifact-url }}
# if: ${{ github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - name: Login to Docker Hub to check credentials
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Build and export
# uses: docker/build-push-action@v6
# with:
# outputs: type=docker,dest=/tmp/hydromt-docker-image.tar
# tags: hydromt
# - name: Run Tests
# run: |
# docker load --input /tmp/hydromt-docker-image.tar
# docker run --env NUMBA_DISABLE_JIT=1 --rm hydromt
# - name: Test Binder integration with repo2docker
# run: |
# pip install jupyter-repo2docker
# repo2docker . echo 'success!'
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# id: upload-docker-release-artifacts
# with:
# name: hydromt-docker-image
# path: /tmp/hydromt-docker-image.tar
notify:
needs:
- pypi
- docs
# - docker
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add comment to PR
env:
GH_TOKEN: ${{ github.token }}
pypi_url: ${{needs.pypi.outputs.url}}
# docker_url: ${{needs.docker.outputs.url}}
docs_url: ${{needs.docs.outputs.url}}
run: |
echo "The new release artifacts have been generated and tested. You can download and inspect them if you want by using the links below: " > comment.txt
echo " - pypi: $pypi_url" >> comment.txt
echo " - docs: $docs_url" >> comment.txt
export PR_ID=$(gh pr list --state "open" --author "app/github-actions" --search "release" --json "number" --jq '. | first | .number')
gh pr comment $PR_ID --body-file comment.txt