forked from tobywf/pasteboard
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (126 loc) · 3.79 KB
/
release.yaml
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
name: Release
on:
push:
branches:
- workflow_release
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build-release:
name: build-release
runs-on: macos-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Create artifacts directory
shell: bash
run: mkdir artifacts
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: pip install poetry
- name: Build wheel
if: matrix.python-version != 3.9
shell: bash
run: poetry build --format "wheel"
- name: Build wheel and sdist
if: matrix.python-version == 3.9
shell: bash
run: poetry build
- name: Resolve wheel name
id: resolve_wheel
shell: bash
run: |
wheel_path="$(echo dist/pasteboard-*.whl)"
echo "::set-output name=path::$wheel_path"
echo "wheel path: $wheel_path"
wheel_name="${wheel_path##*/}"
echo "::set-output name=name::$wheel_name"
echo "wheel name: $wheel_name"
- name: Upload wheel to artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: ${{ steps.resolve_wheel.outputs.path }}
- name: Resolve tar.gz name
id: resolve_targz
if: matrix.python-version == 3.9
shell: bash
run: |
targz_path="$(echo dist/pasteboard-*.tar.gz)"
echo "::set-output name=path::$targz_path"
echo "tar.gz path: $targz_path"
targz_name="${targz_path##*/}"
echo "::set-output name=name::$targz_name"
echo "tar.gz name: $targz_name"
- name: Upload tar.gz to artifacts
if: matrix.python-version == 3.9
uses: actions/upload-artifact@v2
with:
name: artifacts
path: ${{ steps.resolve_targz.outputs.path }}
publish-release:
name: publish-release
needs: ['build-release']
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: pip install poetry
- name: Get release download URL
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts
- name: Create dist directory
shell: bash
run: mkdir dist
- name: Copy wheels
shell: bash
run: cp artifacts/*.whl dist/
- name: Copy tar.gz
shell: bash
run: cp artifacts/*.tar.gz dist/
- name: List all artifacts
shell: bash
run: ls -l dist/
- name: Get the branch and tag
id: info
shell: bash
run: |
branch="${GITHUB_REF#refs/heads/}"
echo "$branch"
if [[ "$branch" == "workflow_release" ]]; then
echo "::set-output name=version::TEST-0.0.0"
echo "::set-output name=dry_run::--dry-run"
else
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
echo "::set-output name=dry_run::"
fi
echo "::set-output name=date::$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')"
- name: Create release
shell: bash
run: |
set -x
hub release create \
--draft \
--message "${{ steps.info.outputs.version }} (${{ steps.info.outputs.date }})" \
$(find ./dist -type f -printf "-a %p ") \
"${{ steps.info.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
run: |
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
poetry publish ${{ steps.info.outputs.dry_run }}