Skip to content

Commit

Permalink
feat: Github action for "release" and "publish_package" (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-volue committed Dec 14, 2023
1 parent 147785b commit 2b8ef5b
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 4 deletions.
File renamed without changes.
25 changes: 25 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: Breaking Changes 💥
labels:
- Semver-Major
- breaking-change
- title: Exciting New Features 🎉
labels:
- enhancement
- feature
- title: Bug Fix 🐛
labels:
- bug-fix
- title: Dependencies Update 📦
labels:
- dependencies
- title: Documentation 📝
labels:
- documentation
- title: Other Changes
labels:
- "*"
26 changes: 26 additions & 0 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push:
branches:
- master

name: Create Release

jobs:
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Read version
id: read-version
run: |
version=$(<wapi/VERSION)
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
echo "version is $version"
- name: Create Release
run: gh release create ${{ steps.read-version.outputs.VERSION }} --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish package

on:
push:
branches:
- master

workflow_dispatch:
inputs:
version:
description: "Version to publish"
required: false
default: ""

jobs:
publish-package:
timeout-minutes: 10
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
with:
python-version: 3.11

- run: pip install -U twine wheel

- name: Read version
id: read-version
run: |
# override VERSION file with input from dispatch action
if [ ${{ github.event_name }} == "workflow_dispatch" ]; then
version_input=${{ github.event.inputs.version }}
echo $version_input > wapi/VERSION
fi
version=$(<wapi/VERSION)
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
echo "version is $version"
- name: Build dist
id: build-dist
run: |
VERSION=${{ steps.read-version.outputs.VERSION }}
rm -rf dist
python setup.py sdist bdist_wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

here = os.path.abspath(os.path.dirname(__file__))
# Get current version from the VERSION file
with open(os.path.join(here, 'VERSION')) as fv:
version = fv.read()
with open(os.path.join(here, 'wapi/VERSION')) as fv:
version = fv.read().strip()

install_requires = [
'requests >= 2.18',
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions wapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#
# Wattsight API access library
#

import os
from .session import Session
from . import auth, curves, events, session, util

VERSION = __version__ = '0.7.11'
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'VERSION')) as fv:
VERSION = __version__ = fv.read().strip()

0 comments on commit 2b8ef5b

Please sign in to comment.