11name : " Publish new release"
22
33on :
4+ workflow_dispatch :
45 push :
56 tags :
67 - v[0-9]+.*
@@ -14,78 +15,59 @@ jobs:
1415 packaging :
1516 name : Build wheels on ${{ matrix.os }}
1617 runs-on : ${{ matrix.os }}
17- if : startsWith(github.ref, 'refs/tags/') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
18+ if : startsWith(github.ref, 'refs/tags/') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) || github.event_name == 'workflow_dispatch'
1819 strategy :
1920 matrix :
20- os : [ubuntu-20.04, windows-2019, macos-10.15]
21+ os :
22+ - ubuntu-latest
2123
2224 steps :
2325 - uses : actions/checkout@v2
26+ if : github.event_name != 'workflow_dispatch'
27+
28+ - uses : actions/checkout@v2
29+ if : github.event_name == 'workflow_dispatch'
30+ with :
31+ ref : ' master'
2432
2533 - name : Get history and tags for SCM versioning to work
2634 run : |
2735 git fetch --prune --unshallow
2836 git fetch --depth=1 origin +refs/tags/*:refs/tags/*
2937
30- - name : Extract version from tag name (Unix)
31- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && runner.os != 'Windows'
32- run : |
33- TAG_NAME="${GITHUB_REF/refs\/tags\//}"
34- VERSION=${TAG_NAME#v}
35-
36- echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
38+ # ========================================================================
3739
3840 - name : Extract version from branch name (for release branches) (Unix)
3941 if : github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/') && runner.os != 'Windows'
4042 run : |
4143 BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
4244 VERSION=${BRANCH_NAME#release/}
43-
44- echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
45- git tag v${RELEASE_VERSION} master
45+ git tag v${VERSION} master
4646
4747 - name : Extract version from branch name (for hotfix branches) (Unix)
4848 if : github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'hotfix/') && runner.os != 'Windows'
4949 run : |
5050 BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
5151 VERSION=${BRANCH_NAME#hotfix/}
52+ git tag v${VERSION} master
5253
53- echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
54- git tag v${RELEASE_VERSION} master
55-
56-
57- - name : Extract version from tag name (Windows)
58- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && runner.os == 'Windows'
59- run : |
60- $TAG_NAME = $GITHUB_REF -replace "refs/tags/",""
61- $VERSION = $TAG_NAME -replace "v",""
62-
63- Write-Output "RELEASE_VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
54+ # ------------------------------------------------------------------------
6455
6556 - name : Extract version from branch name (for release branches) (Windows)
6657 if : github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/') && runner.os == 'Windows'
6758 run : |
6859 $BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
6960 $VERSION = $BRANCH_NAME -replace "release/",""
61+ git tag v${VERSION} master
7062
71- Write-Output "RELEASE_VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
72- git tag v${RELEASE_VERSION} master
73-
74- - name : Extract version from branch name (for hotfix branches) (Unix)
63+ - name : Extract version from branch name (for hotfix branches) (Windows)
7564 if : github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'hotfix/') && runner.os == 'Windows'
7665 run : |
7766 $BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
7867 $VERSION = $BRANCH_NAME -replace "hotfix/",""
68+ git tag v${VERSION} master
7969
80- Write-Output "RELEASE_VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
81- git tag v${RELEASE_VERSION} master
82-
83- - name : Build wheels
84- uses : joerick/cibuildwheel@v1.11.1
85- env :
86- CIBW_ARCHS : auto64
87- CIBW_SKIP : cp27-* pp* cp35-*
88- CIBW_BEFORE_BUILD : python -m pip install pybind11
70+ # ========================================================================
8971
9072 - name : Build source distribution
9173 if : runner.os == 'Linux'
@@ -101,11 +83,21 @@ jobs:
10183 name : packages
10284 path : ./wheelhouse/*
10385
86+
10487 release :
10588 name : Publish new release
10689 runs-on : ubuntu-latest
107- needs : packaging
90+ needs :
91+ - packaging
10892 steps :
93+ - name : Extract version from tag name (workflow_dispatch)
94+ if : github.event_name == 'workflow_dispatch'
95+ run : |
96+ TAG_NAME=$(git describe --tags `git rev-list --tags --max-count=1`)
97+ VERSION=${TAG_NAME#v}
98+
99+ echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
100+
109101 - name : Extract version from tag name
110102 if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
111103 run : |
@@ -130,8 +122,18 @@ jobs:
130122
131123 echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
132124
125+ # ------------------------------------------------------------------------
126+ # Checkout repository to get CHANGELOG
127+
133128 - uses : actions/checkout@v2
129+ if : github.event_name != 'workflow_dispatch'
130+
131+ - uses : actions/checkout@v2
132+ if : github.event_name == 'workflow_dispatch'
133+ with :
134+ ref : ' master'
134135
136+ # ------------------------------------------------------------------------
135137 # Downloads all to directories matching the artifact names
136138 - uses : actions/download-artifact@v2
137139
@@ -164,7 +166,7 @@ jobs:
164166 upload_to_pypi :
165167 name : Upload to PyPI
166168 runs-on : ubuntu-latest
167- needs : release # Only upload to PyPi if everything was successful
169+ needs : release
168170 steps :
169171 - uses : actions/setup-python@v2
170172
@@ -181,7 +183,9 @@ jobs:
181183 master_to_develop_pr :
182184 name : Merge master back into develop
183185 runs-on : ubuntu-latest
184- needs : release # Only create PR if everything was successful
186+ needs :
187+ - release
188+ - upload_to_pypi
185189 steps :
186190 - name : Merge master into develop branch
187191 uses : thomaseizinger/create-pull-request@1.1.0
0 commit comments