Skip to content

Commit

Permalink
97 automatically build and push to pypi (#426)
Browse files Browse the repository at this point in the history
* Start release workflow

* Build and publish to python package on tag push

* Make release

* Rename code quality and add commit of linting fixes

* Add missing colon

* Parallel code quality

* Remove testpypi from release

* Remove type check from analysis job

* Rename build docs
  • Loading branch information
kjy5 authored Jan 11, 2025
1 parent 4320154 commit 4631d27
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
workflow_call:

jobs:
build:
name: Build
build-docs:
name: Build Documentation

runs-on: ubuntu-latest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: Auto Format and Lint
name: Code Quality

on:
pull_request:
push:
branches:
- main
merge_group:

jobs:
autoformat-and-lint:
name: Auto Format and Lint
static-analysis:
name: Static Analysis
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
Expand All @@ -22,27 +21,39 @@ jobs:
ref: ${{ github.head_ref }}
token: ${{ secrets.WORKFLOW_COMMIT }}

- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"

- name: 📦 Install Hatch
uses: pypa/hatch@install

- name: 📝 Format Code
run: hatch fmt -f
run: hatch fmt

- name: ✅ Commit code format changes
- name: ✅ Commit Code Format Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Auto format code"
commit_message: "Hatch static analysis"
skip_fetch: true
skip_checkout: true

type-check:
name: Type Check
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest

steps:
- name: 🛎 Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.WORKFLOW_COMMIT }}

- name: 🧶 Lint
run: hatch fmt --check
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"

- name: 📦 Install Hatch
uses: pypa/hatch@install

- name: 🔍 Type Check
run: hatch run check
run: hatch run check
79 changes: 79 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release Version

on:
push:
tags:
- "v*"

jobs:
# Publish Python package to PyPI.
publish-to-pypi:
name: Publish to PyPI

runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/ephys-link

permissions:
id-token: write

steps:
- name: 🛎 Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"

- name: 📦 Install Hatch
uses: pypa/hatch@install

- name: 🔨 Build Package
run: hatch build

- name: 📦 Publish Distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

# Build Windows executable and make release.
build-and-release:
name: Build Executable and Release

runs-on: windows-latest

steps:
- name: 🛎 Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: "pip"

- name: 📦 Install Hatch
uses: pypa/hatch@install

- name: 🔨 Build Executable
run: hatch run exe

- name: 🤐 Zip Build Folder
# FIXME: Need correct CLI with correct folder name.
run: Compress-Archive -Path dist/ephys-link-${{ github.ref_name }} -Destination dist/ephys-link-${{ github.ref_name }}.zip

- name: 📦 Make Release
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
# FIXME: Use correct name.
artifacts: "dist/ephys-link-${{ github.ref_name }}.zip,dist/ephys-link-${{ github.ref_name }}.exe"
artifactErrorsFailBuild: true
generateReleaseNotes: true
prerelease: ${{ contains(github.ref_name, "a") || contains(github.ref_name, "b") || contains(github.ref_name, "c") || contains(github.ref_name, "d") }}

0 comments on commit 4631d27

Please sign in to comment.