Skip to content

Commit 202a164

Browse files
committed
Automated build and release per rpanderson/workflow-sandbox 0.5.0.dev2
1 parent 1c2c349 commit 202a164

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- maintenance/*
7+
- automated_release
8+
create:
9+
tags:
10+
- 'v[0-9]+.[0-9]+.[0-9]+*'
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
build:
18+
name: Build and Release
19+
runs-on: ubuntu-latest
20+
env:
21+
PACKAGE_NAME: labscript-devices
22+
SCM_VERSION_SCHEME: release-branch-semver
23+
SCM_LOCAL_SCHEME: no-local-version
24+
if: github.repository == 'rpanderson/labscript-devices' && (github.event_name != 'create' || github.event.ref_type != 'branch')
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
- name: Unshallow
29+
if: github.event.ref_type != 'tag'
30+
run: |
31+
git fetch --prune --unshallow
32+
git tag -d $(git tag --points-at HEAD)
33+
- name: Install Python
34+
uses: actions/setup-python@v2
35+
with:
36+
python-version: 3.8
37+
- name: Build Distributions
38+
run: |
39+
python -m pip install --upgrade pip setuptools wheel
40+
pip install -U git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5fd42cb257c86e6dbe720eaee6d1e2c9b
41+
python setup.py sdist bdist_wheel
42+
SCM_VERSION=$(python setup.py --version)
43+
echo "::set-env name=SCM_VERSION::$SCM_VERSION"
44+
- name: Publish on TestPyPI
45+
if: github.event.ref_type == 'tag' || contains(env.SCM_VERSION, 'dev')
46+
uses: pypa/gh-action-pypi-publish@master
47+
with:
48+
user: __token__
49+
password: ${{ secrets.testpypi }}
50+
repository_url: https://test.pypi.org/legacy/
51+
- name: Get Version Number
52+
if: github.event.ref_type == 'tag'
53+
run: |
54+
VERSION="${GITHUB_REF/refs\/tags\/v/}"
55+
echo "::set-env name=VERSION::$VERSION"
56+
- name: Create GitHub Release
57+
if: github.event.ref_type == 'tag'
58+
id: create_release
59+
uses: actions/create-release@latest
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
with:
63+
tag_name: ${{ github.event.ref }}
64+
release_name: ${{ env.PACKAGE_NAME }} ${{ env.VERSION }}
65+
draft: true
66+
prerelease: ${{ contains(github.event.ref, 'rc') }}
67+
- name: Upload Release Asset
68+
if: github.event.ref_type == 'tag'
69+
uses: actions/upload-release-asset@v1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
upload_url: ${{ steps.create_release.outputs.upload_url }}
74+
asset_path: ./dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
75+
asset_name: ${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz
76+
asset_content_type: application/gzip
77+
- name: Publish on PyPI
78+
if: github.event.ref_type == 'tag'
79+
uses: pypa/gh-action-pypi-publish@master
80+
with:
81+
user: __token__
82+
password: ${{ secrets.pypi }}

0 commit comments

Comments
 (0)