-
Notifications
You must be signed in to change notification settings - Fork 4
112 lines (107 loc) · 3.51 KB
/
release_github.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
name: Create a github release for the spark-client Python library
env:
BRANCH: ${{ github.ref_name }}
# SNAP_VERSION: 3.3.2
VERSION: 0.0.0
# pkg_base: https://github.com/canonical/spark-k8s-toolkit-py/archive/refs/tags/v${{env.VERSION}}
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
checks:
name: Check build condition for spark libs
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
python-version:
- '3.9'
- '3.10'
steps:
- id: checkout
name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH }}
fetch-depth: 0
- id: setup-python
name: Setup Python
uses: actions/setup-python@v2.2.2
with:
python-version: ${{matrix.python-version}}
architecture: x64
- id: code-checks
name: Make sure the code follows conventions and tests correctly
run: |
make checks
autorelease:
name: Release the package on github
needs: checks
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
steps:
- id: checkout
name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH }}
fetch-depth: 0
- id: setup-python
name: Setup Python
uses: actions/setup-python@v2.2.2
with:
python-version: '3.10'
architecture: x64
- id: build-package
name: Build package
run: |
make checks
poetry build
- name: Add version to environment vars
run: |
echo "PROJECT_VERSION=${{ env.VERSION }}" >> $GITHUB_ENV
- name: Check if tag version matches project version
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
echo $TAG
echo $PROJECT_VERSION
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
- name: Create Github Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: ".github/RELEASE-TEMPLATE.md"
files: |
dist/spark_client-${{env.PROJECT_VERSION}}-py3-none-any.whl
dist/spark_client-${{env.PROJECT_VERSION}}.tar.gz
test:
name: Test Release
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- autorelease
- checks
steps:
- id: check-tar-gz
name: Check tar.gz package
run: |
# check if release is now published and available
echo "Checking latest available Spark package release v${{env.VERSION}}."
STATUSCODE=$(curl --silent --head https://github.com/canonical/spark-k8s-toolkit-py/archive/refs/tags/v${{env.VERSION}}.tar.gz | head -n 1 | cut -d' ' -f2)
if [[ ${STATUSCODE} -ne 200 ]] && [[ ${STATUSCODE} -ne 302 ]]; then exit 1; fi
- id: download-package
name: Download wheel package
run: |
# check if release is now published and available
echo "Downloading latest available Spark wheel package release v${{env.VERSION}}."
wget https://github.com/canonical/spark-k8s-toolkit-py/archive/refs/tags/v${{env.VERSION}}-py3-none-any.whl --no-check-certificate
- id: install-package
name: Install wheel package file
run: |
pip install ./spark_client-${{env.VERSION}}-py3-none-any.whl