-
Notifications
You must be signed in to change notification settings - Fork 112
155 lines (136 loc) · 4.7 KB
/
pipy_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
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
155
# adapted from
# - https://medium.com/@VersuS_/automate-pypi-releases-with-github-actions-4c5a9cfe947d
# - https://github.com/facebookresearch/fairscale/blob/main/.github/workflows/release.yml
name: MyoSuite PyPI Release
# on: [push]
# on:
# push:
# tags:
# - '*'
on:
workflow_dispatch:
inputs:
name:
description: 'Release Type (major, minor, patch)'
default: 'patch'
required: true
# # Upon running the following instructions
# # > git tag 0.0.1 # or whatever version you want
# # > git push origin --tags
# # The following operations will be run
# # 1. Update version according to major | minor | patch and use the new version as `tag name`
# # 2. Use the `tag name` as `release version`
# # 3. Build the PyPI package by using /myosuite/__init__.py version
# # 4. Upload the package
# # 5. Test Upload
jobs:
# 1. Update version according to major | minor | patch and use the new version as `tag name`
get_next_version:
runs-on: ubuntu-latest
steps:
- name: checkout-repo-content
uses: actions/checkout@v2
- name: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: get next version and tag
id: get-next-version-and-tag
run: |
output=$(python3 .github/release_utils.py --release-type ${{ github.event.inputs.name }})
echo $output
new_version=$(echo $output | awk '{print $1}')
new_tag=$(echo $output | awk '{print $2}')
echo "new version is $new_version"
echo "new tag is $new_tag"
echo ::set-output name=version::$new_version
echo ::set-output name=tag::$new_tag
outputs:
new_version: ${{ steps.get-next-version-and-tag.outputs.version }}
new_tag: ${{ steps.get-next-version-and-tag.outputs.tag }}
pypi_package_build_and_release:
name: Build and publish PyPI wheel
runs-on: ubuntu-latest
needs: get_next_version
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Install pypa/setuptools
run: >-
python -m
pip install wheel
# update the version number in version.py
- name: update version
id: update-version
run : |
echo "current folder = $PWD"
echo "current branch = $(git branch --show-current)"
output=$(python3 .github/release_utils.py --release-type ${{ github.event.inputs.name }} --update-version)
# 2. Use the `tag name` as `release version`
# add and commit the updated version.py to main
- name: add and commit to main
uses: EndBug/[email protected]
with:
#token: ${{ secrets.REPO_TOKEN }}
author_name: ${{ secrets.AUTHOR_NAME }}
author_email: ${{ secrets.AUTHOR_EMAIL }}
branch: main
default_author: github_actor
message: '${{ needs.get_next_version.outputs.new_version }} release'
pathspec_error_handling: exitAtEnd
# Arguments for the git pull command. Use NO-PULL to avoid the action pulling at all.
# Default: '--no-rebase'
pull: 'NO-PULL'
tag: '${{ needs.get_next_version.outputs.new_tag }}'
# 3. Build the PyPI packeage
- name: Build a binary wheel
run: >-
python setup.py sdist bdist_wheel
# 4. Upload the package
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# - name: Publish distribution to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
test_latest_PyPI:
needs: pypi_package_build_and_release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
steps:
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Prepare Linux
if: ${{ runner.os == 'Linux' }}
run: >
sudo apt-get install -y \
libgl1-mesa-dev \
libgl1-mesa-glx \
libglew-dev \
libosmesa6-dev \
software-properties-common
sudo apt-get install -y patchelf
- name: Prepare macOS
if: ${{ runner.os == 'macOS' }}
run: brew install gcc@9
- shell: bash
run: |
echo "Test MyoSuite PyPI wheel"
pip install -U myosuite
python -m myosuite.tests.test_myo