-
Notifications
You must be signed in to change notification settings - Fork 86
58 lines (48 loc) · 1.96 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
name: Release
on:
release:
types: [published]
workflow_call:
jobs:
publish_pkg:
if: ${{ (github.event_name == 'release' && github.event.action == 'published') }}
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Cache dev-py environment
uses: actions/cache@v3
with:
path: .venv
key: cache_dev_py_ubuntu22_${{ hashFiles('pdm.lock') }}
- name: Get workflow ID
id: workflow_id
run: |
workflow_data=$(curl -s -X GET \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.VIZZUHQ_GITHUB_API }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows")
workflow_id=$(echo $workflow_data | jq -r '.workflows[] | select(.name == "CI-CD") | .id')
echo "workflow_id=${workflow_id}" >> $GITHUB_OUTPUT
- name: Get run ID
id: run_id
run: |
run_data=$(curl -s -X GET \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.VIZZUHQ_GITHUB_API }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/actions/workflows/${{ steps.workflow_id.outputs.workflow_id }}/runs?branch=main")
run_id=$(echo $run_data | jq -r '.workflow_runs[0].id')
echo "run_id=${run_id}" >> $GITHUB_OUTPUT
- name: Cache package
uses: actions/cache@v3
with:
path: dist/
key: cache_package_${{ steps.run_id.outputs.run_id }}
- name: Release package
run: ./.venv/bin/python -m twine upload -u "__token__" -p "${{ secrets.PYPI_API_TOKEN }}" dist/*.tar.gz dist/*.whl
- name: Upload package
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh release upload ${{ github.event.release.tag_name }} dist/*.tar.gz dist/*.whl --clobber