|
1 | | -name: Publish |
| 1 | +name: Release |
2 | 2 | on: |
3 | | - release: |
4 | | - types: |
5 | | - - created |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - workflow_release |
| 6 | + tags: |
| 7 | + - 'v[0-9]+.[0-9]+.[0-9]+' |
6 | 8 | jobs: |
7 | | - publish: |
8 | | - name: publish |
| 9 | + release: |
| 10 | + name: release |
9 | 11 | runs-on: ubuntu-latest |
10 | 12 | steps: |
11 | | - - uses: actions/checkout@v2 |
| 13 | + - name: Get the branch and tag |
| 14 | + id: info |
| 15 | + run: | |
| 16 | + branch="${GITHUB_REF#refs/heads/}" |
| 17 | + echo "$branch" |
| 18 | + if [[ "$branch" == "workflow_release" ]]; then |
| 19 | + echo "::set-output name=version::TEST-0.0.0" |
| 20 | + echo "::set-output name=draft::true" |
| 21 | + else |
| 22 | + echo "::set-output name=version::${GITHUB_REF#refs/tags/}" |
| 23 | + echo "::set-output name=draft::false" |
| 24 | + fi |
| 25 | + echo "::set-output name=date::$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')" |
| 26 | +
|
12 | 27 | - name: Set up Python |
13 | 28 | uses: actions/setup-python@v1 |
14 | 29 | with: |
15 | 30 | python-version: '3.7' |
| 31 | + |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v2 |
| 34 | + |
16 | 35 | - name: Install dependencies |
17 | 36 | run: | |
18 | 37 | python -m pip install --upgrade pip |
19 | 38 | pip install poetry |
| 39 | +
|
20 | 40 | - name: Build |
21 | 41 | run: | |
22 | 42 | poetry build |
23 | | - - name: Publish |
| 43 | +
|
| 44 | + - name: Create GitHub release |
| 45 | + uses: softprops/action-gh-release@v1 |
| 46 | + env: |
| 47 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + with: |
| 49 | + draft: ${{ steps.info.outputs.draft }} |
| 50 | + files: | |
| 51 | + dist/xml_dataclasses-*-py3-none-any.whl |
| 52 | + dist/xml_dataclasses-*.tar.gz |
| 53 | + name: ${{ steps.info.outputs.version }} (${{ steps.info.outputs.date }}) |
| 54 | + tag_name: ${{ steps.info.outputs.version }} |
| 55 | + |
| 56 | + - name: Publish to PyPI |
| 57 | + if: ${{ steps.info.outputs.draft == false }} |
24 | 58 | run: | |
25 | 59 | poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}" |
26 | 60 | poetry publish |
0 commit comments