Skip to content

Commit

Permalink
Release CI workflow (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz authored Feb 1, 2024
1 parent 38c27d2 commit 05d9921
Showing 1 changed file with 105 additions and 61 deletions.
166 changes: 105 additions & 61 deletions .github/workflows/cd_release.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,109 @@
name: CD - Publish on PyPI
---
name: Publish on Test PyPI and PyPI

on:
release:
types:
- published
push:
branches:
# Commits pushed to release/ branches are published on Test PyPI if they
# have a new version number.
- release/**
tags:
# Tags that start with the "v" prefix are published on PyPI.
- v*

jobs:
publish:
name: External
uses: SINTEF/ci-cd/.github/workflows/[email protected]
if: github.repository == 'CasperWA/voila-optimade-client' && startsWith(github.ref, 'refs/tags/20')
with:
# General
git_username: CasperWA
git_email: "[email protected]"
release_branch: develop
install_extras: "[dev]"

# PyPI publication
python_package: true
python_version_build: "3.9"
package_dirs: "ipyoptimade"
version_update_changes_separator: ";"
version_update_changes: |
{package_dir}/__init__.py;__version__ = .+;__version__ = \"{version}\"
setup.py;version=([^,]+),;version=\"{version}\",
{package_dir}/informational.py;Client version.*</code>;Client version</b>: <code>{version}</code>
{package_dir}/cli/run.py;VERSION = \".+\";VERSION = \"{version}\"
build_libs: "build"
build_cmd: "python -m build"
publish_on_pypi: true

# Documentation
update_docs: false
secrets:
PyPI_token: ${{ secrets.pypi_password }}
PAT: ${{ secrets.RELEASE_PAT }}

update-stable:
name: Update `stable` branch
needs: publish
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: stable
persist-credentials: false

- name: Setup git config
run: |
git config --global user.name "CasperWA"
git config --global user.email "[email protected]"
- name: Make `stable` branch equal to `develop` branch
run: git merge --ff-only origin/develop

- name: Update `stable` branch
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.RELEASE_PAT }}
branch: stable

build:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install pypa/build
run: python -m pip install build

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: Upload distribution artifact
uses: actions/upload-artifact@v4
with:
name: release
path: dist/


publish-test:

name: Build and publish on TestPyPI
if: >
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest

environment:
name: Test PyPI
url: https://test.pypi.org/project/ipyoptimade/

steps:
- uses: actions/download-artifact@v4
name: Download distribution artifact
with:
name: release
path: dist/

- name: Publish distribution on Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/heads/release/')
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

publish:

name: Build and publish on PyPI
if: startsWith(github.ref, 'refs/tags')

needs: [build]
runs-on: ubuntu-latest

environment:
name: PyPI
url: https://pypi.org/project/ipyoptimade/

steps:

- uses: actions/download-artifact@v4
name: Download distribution artifact
with:
name: release
path: dist/

- uses: softprops/[email protected]
name: Create release
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
dist/*
generate_release_notes: true

- name: Publish distribution on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 05d9921

Please sign in to comment.