80 lines (63 loc) · 3.11 KB
/
main.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
name: Build and deploy to PyPI
on:
push:
branches:
- master
schedule:
# Runs on the 1st of every month at 4PM
- cron: "0 16 1 * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
GIT_AUTHOR_NAME: "Jason Yao"
GIT_AUTHOR_EMAIL: "Hello@JasonYao.com"
BRANCH_REF_NAME: ${{ github.head_ref }}
SHA_COMMIT_HASH: ${{ github.sha }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
# Deploy pipeline metadata
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- name: Extracts the current branch name
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- run: echo "🔎 The name of your branch is ${{ steps.extract_branch.outputs.branch }} and your repository is ${{ github.repository }}."
# Sets up environment
- name: Checkout repo code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Python 3 setup
uses: actions/setup-python@v2
with:
python-version: '3.9' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install dependencies
run: bin/install_dependencies
- name: Run linters
run: bin/lint
- name: Install project dependencies
run: pip install -e .
- name: Extracts the current deployment version number
run: echo "##[set-output name=current_version;]$(cut -d'"' -f 2 < pydotfiles/version.py)"
id: current_version
# # We comment all our tests here since a large portion of new code is going through separate codepaths,
# # and we have better things to do than to update unit tests for legacy codepaths
# - name: Run tests
# # Pytest --pep8 is deprecated and just fails, so we removed it here
# run: pytest --cov=pydotfiles tests/ --cov-fail-under=30 -m "not local"
- name: Generate release (wheels)
run: bin/generate-release ${{ steps.extract_branch.outputs.branch }}
- name: Extracts the new deployment version number
run: echo "##[set-output name=new_version;]$(cut -d'"' -f 2 < pydotfiles/version.py)"
id: new_version
- run: echo "🔎 The current version is ${{ steps.current_version.outputs.current_version }} and the new version is ${{ steps.new_version.outputs.new_version }}."
- name: Publish package
# Per https://github.com/marketplace/actions/pypi-publish?version=v1.5.1#usage,
# We want to only upload packages that are a tagged commit
if: github.ref == 'refs/heads/master' && (steps.current_version.outputs.current_version != steps.new_version.outputs.new_version)
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}