Skip to content

Workflow for release #9

Workflow for release

Workflow for release #9

Workflow file for this run

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