-
Notifications
You must be signed in to change notification settings - Fork 4
137 lines (127 loc) · 4.47 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Create a github release for the spark8t Python library
env:
BRANCH: ${{ github.ref_name }}
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
tests:
uses: ./.github/workflows/ci-tests.yaml
release_checks:
name: Checks before pkg build
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
steps:
- id: checkout
name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}
fetch-depth: 0
- id: setup_python
name: Setup Python
uses: actions/setup-python@v5.1.0
with:
python-version: '3.10'
architecture: x64
- id: install_environment
name: Set up build environment
run: |
make setup
- id: package_metadata
name: Fetch package metadata
run: |
NAME=$(poetry version | awk '{print $1}')
VERSION=$(poetry version | awk '{print $2}')
echo "name=$NAME" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- id: version_vs_tag_check
name: Check if tag version matches project version
run: |
VERSION=${{ steps.package_metadata.outputs.version }}
BRANCH=${{ env.BRANCH }}
if [[ "$BRANCH" != "v$VERSION" ]]; then exit 1; fi
outputs:
package_name: ${{ steps.package_metadata.outputs.name }}
package_version: ${{ steps.package_metadata.outputs.version }}
autorelease:
name: Release the package on github
needs: [release_checks, tests]
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: true
steps:
- id: checkout
name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH }}
fetch-depth: 0
- id: setup_python
name: Setup Python
uses: actions/setup-python@v5.1.0
with:
python-version: '3.10'
architecture: x64
- id: install_environment
name: Set up build environment
run: |
make setup
- id: build_package
name: Build package
run: |
poetry build
- id: artifact_names
name: Compute artifact names outputs
run: |
_NAME=${{ needs.release_checks.outputs.package_name }}
_VERSION=${{ needs.release_checks.outputs.package_version }}
echo "wheel=${_NAME}-${_VERSION}-py3-none-any.whl" >> "$GITHUB_OUTPUT"
echo "tarball=${_NAME}-${_VERSION}.tar.gz" >> "$GITHUB_OUTPUT"
- 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/${{ steps.artifact_names.outputs.wheel }}
dist/${{ steps.artifact_names.outputs.tarball }}
outputs:
version: ${{ needs.release_checks.outputs.package_version }}
wheel: ${{ steps.artifact_names.outputs.wheel }}
tarball: ${{ steps.artifact_names.outputs.tarball }}
test:
name: Test Release
runs-on: ubuntu-latest
timeout-minutes: 5
env:
DOWNLOADS_PATH: "/releases/download"
needs: [autorelease]
steps:
- id: check-tar-gz
name: Check tar.gz package
run: |
# check if release is now published and available
TARBALL=${{ needs.autorelease.outputs.tarball }}
VERSION=${{ needs.autorelease.outputs.version }}
echo "Checking latest available Spark package release: ${TARBALL}"
STATUSCODE=$(curl --silent --head $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/${{ env.DOWNLOADS_PATH }}/v${VERSION}/${TARBALL} | 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
WHEEL=${{ needs.autorelease.outputs.wheel }}
VERSION=${{ needs.autorelease.outputs.version }}
echo "Downloading latest available Spark wheel package release ${WHEEL}."
wget $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/${{ env.DOWNLOADS_PATH }}/v${VERSION}/${WHEEL} --no-check-certificate
- id: install-package
name: Install wheel package file
run: |
pip install ./${{ needs.autorelease.outputs.wheel }}