-
Notifications
You must be signed in to change notification settings - Fork 23
94 lines (90 loc) · 2.96 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
94
name: Create release
on:
workflow_dispatch:
inputs:
sha:
description: "Commit SHA to create release from"
required: true
tag:
description: "Tag of the release"
required: true
push:
tags:
- 'v*'
jobs:
version-check:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Check package versions
run: python scripts/check_package_versions.py
set-env:
needs: [version-check]
runs-on: ubuntu-latest
outputs:
sha: ${{ env.SHA }}
tag: ${{ env.TAG }}
prerelease: ${{ env.PRERELEASE }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set env on push
if: github.event_name == 'push'
run: |
echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "TAG=$(git tag --points-at HEAD)" >> $GITHUB_ENV
- name: Set env on trigger
if: github.event_name == 'workflow_dispatch'
run: |
echo "SHA=${{ github.event.inputs.sha }}" >> $GITHUB_ENV
echo "TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
- name: Set env if version is pre-release
run: |
echo "PRERELEASE=${{ toJSON(contains(env.TAG, '-')) }}" >> $GITHUB_ENV
- name: Check values
run: |
echo "SHA: ${{ env.SHA }}"
echo "Tag: ${{ env.TAG }}"
echo "Pre-release: ${{ env.PRERELEASE }}"
build-artifacts:
needs: [set-env]
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.set-env.outputs.tag }}
sha: ${{ needs.set-env.outputs.sha }}
create-release:
runs-on: ubuntu-latest
needs: [set-env, build-artifacts]
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
ref: ${{ needs.set-env.outputs.sha }}
- name: Generate changelog
run: python3 scripts/extract_changelog.py ${{ needs.set-env.outputs.tag }} > generated-changelog.md
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Create release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.set-env.outputs.tag }}
name: ${{ needs.set-env.outputs.tag }}
bodyFile: generated-changelog.md
commit: ${{ needs.set-env.outputs.sha }}
allowUpdates: true
prerelease: ${{ fromJSON(needs.set-env.outputs.prerelease) }}
removeArtifacts: true
artifacts: archive-*/**
upload-python-wheel:
runs-on: ubuntu-latest
needs: [set-env, create-release]
if: ${{ !fromJSON(needs.set-env.outputs.prerelease) }}
steps:
- name: Download archive
uses: actions/download-artifact@v2
- name: Install twine
run: python -m pip install twine
- name: Upload wheel
run: python -m twine upload --username __token__ --password ${{ secrets.PYPI_UPLOAD_TOKEN }} archive-pyhq/*