Skip to content

SwanCustomEnvironments v0.0.17 #127

SwanCustomEnvironments v0.0.17

SwanCustomEnvironments v0.0.17 #127

Workflow file for this run

# This workflows will upload a Python Package using Twine when a release is created
# Also a package for node is created and uploaded
# author: Omar.Zapata@cern.ch 2020
name: SWAN CI/CD pipeline
on:
push:
tags:
- '*/v*'
jobs:
build-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set environnment package name and version
run: |
PACKAGE_TAG=${GITHUB_REF#refs/*/}
PACKAGE_NAME=$(echo $PACKAGE_TAG | cut -d / -f 1)
echo "PACKAGE_TAG=$PACKAGE_TAG" >> $GITHUB_ENV
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(echo $PACKAGE_TAG | cut -d / -f 2)" >> $GITHUB_ENV
cd $PACKAGE_NAME
if [ -f 'package.json' ]; then
echo "PACKAGE_JSON=$(echo 1)" >> $GITHUB_ENV
fi
PREV_TAG=$(git describe --tags --match "$PACKAGE_NAME*" --abbrev=0 --exclude "$PACKAGE_TAG" || true)
[ ! -z "$PREV_TAG" ] && PREV_TAG=$PREV_TAG..
EXT_LOWERCASE=$(echo $PACKAGE_NAME | tr '[:upper:]' '[:lower:]')
git --no-pager log $PREV_TAG HEAD --pretty=format:"- %B" -- $PACKAGE_NAME | sed -r "s/($EXT_LOWERCASE|$PACKAGE_NAME): //g" | sed -r "s/\*/ \*/g" > /tmp/release_body.md
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install node
if: ${{env.PACKAGE_JSON}}
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install dependencies
run: |
cd $PACKAGE_NAME
pip install build twine
- name: Build wheel
run: |
cd $PACKAGE_NAME
python -m build
- name: Publish distribution to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
cd $PACKAGE_NAME
twine upload --repository pypi dist/*
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: /tmp/release_body.md
draft: false
prerelease: false
- name: Invoke workflow in jupyter-images
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Update packages of Jupyter images
ref: main
repo: swan-cern/jupyter-images
token: ${{ secrets.WORKFLOW_ACCESS_TOKEN }}
inputs: '{ "package": "${{env.PACKAGE_NAME}}", "version": "${{env.PACKAGE_VERSION}}" }'