-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (144 loc) · 4.49 KB
/
Copy pathpublish.yaml
File metadata and controls
154 lines (144 loc) · 4.49 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
name: Build, Test and Publish
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- main
workflow_dispatch:
jobs:
check-version-txt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# set for bringing the tag inforation for all branches
# use it with caution when git is large
with:
fetch-depth: 0
- name: Tag the release version
run: |
git tag $(cat version.txt)
lint-format-and-static-code-quality-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install pre-commit
run: |
pip install pre-commit
- name: Lint, format, and other static code quality check
run: |
/bin/bash -x run.sh lint:ci
build-sdist-wheel:
# needs:
# - lint-format-and-static-code-quality-checks
# - check-version-txt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
# cache setup for github actions
# https://github.com/actions/cache/blob/main/examples.md#python---pip
# calculating hashcodes for requirements and pyproject.toml -anychanges will create a new key
- name: Cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install build cli
run: |
pip install build
- name: Build python package
run: |
/bin/bash -x run.sh build
# https://github.com/actions/upload-artifact
- name: Upload dist foler and package artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-and-sdist
path: ./dist/*
publish:
needs:
- build-sdist-wheel
- lint-format-and-static-code-quality-checks
- check-version-txt
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/head/main'
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
# https://github.com/actions/download-artifact
- name: Download dist
uses: actions/download-artifact@v4
with:
path: ./dist/
- name: Display structure of downloaded files
run: ls -R ./dist/
- name: Install twine
run: |
pip install twine
- name: Publish to Test Pypi
# if this a push event
if: github.event_name == 'push' && github.ref == 'refs/head/main'
run: |
/bin/bash -x run.sh publish:test
env:
TEST_PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN}}
# - name: publish to Prod Pypi
# if: github.event_name == 'push' && github.ref == 'refs/head/main'
# run: |
# /bin/bash -x run.sh publish:PROD
# env:
# PROD_PYPI_TOKEN: ${{ secrets.PROD_PYPI_TOKEN}}
- name: Push Tags
if: github.event_name == 'push' && github.ref == 'refs/head/main'
run: |
git push origin --tags
# https://docs.github.com/en/actions/learn-github-actions/contexts
dump_contexts_to_log:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
# added two new contexts for secrets and vars
- name: Dump secrets
env:
secrets: ${{ toJson(secrets) }}
run: echo "$secrets"
- name: Dump variables
env:
vars: ${{ toJson(vars) }}
run: echo "$vars"