Skip to content

Commit

Permalink
Add automatic versioning and deploy to PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
alengwenus committed Jan 17, 2024
1 parent bd3f8e6 commit 54e7f01
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ReleaseActions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Release actions"

on:
release:
types: ["published"]

env:
PYTHON_VERSION: "3.x"

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy to PyPi
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
- name: "Set version number from tag"
run: |
echo -n '${{ github.ref_name }}' > ./VERSION
sed -i 's/dev/${{ github.ref_name }}/g' ./src/version.ts
cat ./VERSION
cat ./src/version.ts
- name: Install dependencies
run: |
python -m pip install build twine
./script/bootstrap
- name: Build
run: yarn build

- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m build
twine upload dist/*
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
graft lcn_frontend
global-exclude *.py[cod]
include VERSION
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev
5 changes: 2 additions & 3 deletions build-scripts/env.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ module.exports = {
},
version() {
const version = fs
.readFileSync(path.resolve(paths.polymer_dir, "pyproject.toml"), "utf8")
.match(/version\W+=\W"(.*?)"/);
.readFileSync(path.resolve(paths.polymer_dir, "VERSION"), "utf8")
if (!version) {
throw Error("Version not found");
}
return version[1];
return version.trim();
},
};
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ build-backend = "setuptools.build_meta"

[project]
name = "lcn_frontend"
version = "0.1.0"
license = {text = "MIT License"}
description = "LCN panel for Home Assistant"
keywords = ["Home Assistant", "LCN"]
readme = "README.md"
authors = [
{name = "Andre Lengwenus", email = "[email protected]"},
]
requires-python = ">=3.10.0"
dynamic = ["version"]

[project.urls]
Repository = "https://github.com/alengwenus/lcn-frontend.git"

[tool.setuptools.dynamic]
version = {file = "VERSION"}

[tool.setuptools]
platforms = ["any"]
zip-safe = false
Expand Down
1 change: 1 addition & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION = "dev";

0 comments on commit 54e7f01

Please sign in to comment.