forked from anthony-wang/CrabNet
-
Notifications
You must be signed in to change notification settings - Fork 5
113 lines (99 loc) · 3.39 KB
/
test-publish-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
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
name: Test, Publish, and Release
on:
push:
tags:
- "*.*.*"
workflow_dispatch:
# on:
# release:
# types: [published]
jobs:
flit-publish-gh-release:
name: Test, Publish to PyPI, and Release on GitHub
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
strategy:
max-parallel: 9
fail-fast: true
matrix:
os: [ubuntu-latest] # much slower on Mac and Win, but can use [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9']
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
submodules: recursive
- name: Check Black code style
uses: psf/black@stable #https://black.readthedocs.io/en/stable/integrations/github_actions.html
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install flit torch coveralls pytest # torch is CPU version
flit install
- name: Pytest
run: |
coverage run --source=crabnet -m pytest
- name: Publish to PyPI
run: |
git clean -f # remove untracked files
flit publish
# wait to ensure that the package is available on PyPI (for run_grayskull.py)
sleep 60s # https://stackoverflow.com/questions/21620406/how-do-i-pause-my-shell-script-for-a-second-before-continuing
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
activate-environment: crabnet
- name: Install dependencies
run: |
conda install git conda-build conda-verify anaconda-client pytest conda-forge::grayskull conda-forge::flit conda-forge::coveralls conda-forge::conda-souschef
- name: Build and Publish
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
run: |
conda env list
mkdir scratch
cp LICENSE scratch/
python run_grayskull.py
conda config --append channels conda-forge
conda config --append channels sgbaird
conda config --set anaconda_upload yes
cd scratch
conda build .
conda install --use-local crabnet
cd ..
# - name: Conda PyTest
# run: |
# python -m pytest # torch module not found for some reason
# conda deactivate
- name: "Build Changelog" # https://github.com/marketplace/actions/release-changelog-builder
id: build_changelog
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{steps.build_changelog.outputs.changelog}}
draft: false
prerelease: false
- name: Upload to coveralls
shell: bash -l {0}
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}