Skip to content

Commit

Permalink
build: add basic build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
znicholls committed Apr 21, 2023
1 parent 44ce4d2 commit 2745765
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/release_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Announcements

* Announcement 1

## Changes

* Change 1
25 changes: 25 additions & 0 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Inspired by https://github.com/LaurenceRawlings/python-poetry-cicd/blob/main/.github/workflows/bump.yml
name: Bump version

on: workflow_dispatch

jobs:
bump_version:
name: "Bump version and create changelog"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
- name: Create bump and changelog
id: cz
uses: commitizen-tools/commitizen-action@0.18.1
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
branch: main
check_consistency: true
- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# TODO: take a look at https://github.com/actions/cache/blob/main/caching-strategies.md#make-cache-read-only--reuse-cache-from-centralized-job
# for caching
name: CI-CD
name: CI

on:
pull_request:
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: deploy

on:
push:
tags: ['v*']

defaults:
run:
shell: bash

jobs:
deploy:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry install --no-interaction --all-extras
- name: Add version to environment
run: |
PROJECT_VERSION=$(poetry version --short)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Run tests
run: |
poetry run pytest -r a --doctest-modules
- name: Build package
run: |
poetry build --no-interaction
- name: Check build
run: |
tar -tvf dist/openscm_calibration-*.tar.gz --wildcards '*openscm_calibration/py.typed'
- name: Generate Release Notes
run: |
git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty='format:* %h %s' --no-merges >> ".github/release_template.md"
- name: Create Release Draft
uses: softprops/action-gh-release@v1
with:
body_path: ".github/release_template.md"
draft: true
files: |
dist/openscm_calibration-${{env.PROJECT_VERSION}}-py3-none-any.whl
dist/openscm_calibration-${{env.PROJECT_VERSION}}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ multiprocess = { version = "^0.70.14", optional = true }
tqdm = { version = "^4.65.0", optional = true }
# While waiting for a new release, see
# https://github.com/dnanhkhoa/nb_black/issues/38
nb-black = { version = "^1.0.7", optional = true }
nb-black = { git = "https://github.com/dnanhkhoa/nb_black.git", rev = "50c0f1", optional = true }
corner = { version = "^2.2.1", optional = true }
seaborn = { version = "^0.12.2", optional = true }
h5py = { version = "^3.8.0", optional = true }
Expand Down

0 comments on commit 2745765

Please sign in to comment.