-
Notifications
You must be signed in to change notification settings - Fork 3
93 lines (92 loc) · 3.32 KB
/
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
name: Build and Release
on:
push:
branches:
- master
- maintenance/*
create:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
github_properties:
name: GitHub Properties
runs-on: ubuntu-latest
steps:
- name: Enumerate properties
run: |
echo github.ref: ${{ github.ref }}
echo github.event_name: ${{ github.event_name }}
echo github.event: ${{ github.event }}
echo github.event.name: ${{ github.event.name }}
echo github.event.ref: ${{ github.event.ref }}
echo github.event.ref_type: ${{ github.event.ref_type }}
echo github.event.master_branch: ${{ github.event.master_branch }}
echo github.actor: ${{ github.actor }}
release:
name: Build and Release
runs-on: ubuntu-latest
needs: github_properties
env:
PACKAGE_NAME: workflow-sandbox
if: github.repository == 'rpanderson/workflow-sandbox' && (github.event_name != 'create' || github.event.ref_type != 'branch')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
if: github.event.ref_type == 'branch'
run: |
git fetch --prune --unshallow
git describe --tags
git log -1
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Build Distribution
env:
SCM_LOCAL_SCHEME: no-local-version
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -U git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5fd42cb257c86e6dbe720eaee6d1e2c9b
python setup.py sdist bdist_wheel
SCM_VERSION=$(python setup.py --version)
echo "::set-env name=SCM_VERSION::$SCM_VERSION"
- name: Publish on TestPyPI
if: github.event.ref_type == 'tag' || contains(env.SCM_VERSION, 'dev')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.testpypi }}
repository_url: https://test.pypi.org/legacy/
- name: Get Version Number
if: github.event.ref_type == 'tag'
run: |
VERSION="${GITHUB_REF/refs\/tags\/v/}"
echo "::set-env name=VERSION::$VERSION"
- name: Create GitHub Release
if: github.event.ref_type == 'tag'
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.ref }}
release_name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }}
draft: true
prerelease: ${{ contains(github.event.ref, 'rc') }}
- name: Upload Release Asset
if: github.event.ref_type == 'tag'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
asset_content_type: application/gzip
- name: Publish on PyPI
if: github.event.ref_type == 'tag'
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi }}