Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributable ZIP-package #129

Merged
merged 34 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6898eb4
Removing redundant env var in CI.
RobinTail Jul 28, 2023
b3a5fec
Add sample releasing steps until the artifact upload.
RobinTail Jul 28, 2023
c6b1299
Add missing dependency installation step.
RobinTail Jul 28, 2023
f84ead7
Including changelog into the manifest.
RobinTail Jul 28, 2023
ffd1b2c
Add integration test.
RobinTail Jul 28, 2023
f8153f8
Removing JS file from the repo.
RobinTail Jul 28, 2023
6570399
Removing the changes checking step from UI CI.
RobinTail Jul 28, 2023
5f038c9
Add miniver installation step.
RobinTail Jul 28, 2023
fd27ce5
Add versioning step.
RobinTail Jul 28, 2023
eccc275
Installing miniver using GitHub Codespace.
RobinTail Jul 28, 2023
db835fa
Ignoring some files.
RobinTail Jul 28, 2023
6d905bd
Using module name for importing version.
RobinTail Jul 28, 2023
5ea6bd4
Add EOL.
RobinTail Jul 28, 2023
cd126c4
Adding the miniver lines to setup.py.
RobinTail Jul 28, 2023
958a5c4
Add Wheels installation step.
RobinTail Jul 28, 2023
9ef4c5e
CI: excluding _version.py from coverage report.
RobinTail Jul 28, 2023
eb885d9
Changing the trigger for Release workflow.
RobinTail Jul 28, 2023
1f4a92c
Trying checking with depth 0.
RobinTail Jul 28, 2023
3617ec6
Only trigger on published type of release.
RobinTail Jul 28, 2023
0b7f83e
Patching miniver for using non-annotated tags.
RobinTail Jul 28, 2023
c8233e6
Add the asset attachment job.
RobinTail Jul 28, 2023
f4197a1
Using specific version of get-release action.
RobinTail Jul 28, 2023
bc60396
Changing the package download link for pip.
RobinTail Jul 29, 2023
18768ac
EOL for .gitattributes
RobinTail Jul 29, 2023
d6d3f1a
minor, empty line in setup.py
RobinTail Jul 29, 2023
86b6cbd
Fix padding in release workflow.
RobinTail Jul 29, 2023
b10b2e6
Readme: changing the latest ditribution link.
RobinTail Jul 29, 2023
a33aa2a
Revert "Trying checking with depth 0."
RobinTail Jul 29, 2023
48d6a0a
Extracting versions into env, testing installation against variety.
RobinTail Jul 29, 2023
60738a6
Fix: add wheel installation step to integration test.
RobinTail Jul 29, 2023
72ef16d
Minor: title.
RobinTail Jul 29, 2023
5312570
Fix: build job name.
RobinTail Jul 29, 2023
8563cae
Ref: organizing the steps: UI first, Python next.
RobinTail Jul 29, 2023
932bc3f
Changelog: the future 2.3.0.
RobinTail Jul 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
octoprint_octorelay/_static_version.py export-subst
21 changes: 4 additions & 17 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ jobs:
node-version: 18.x
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-yarn
with:
path: ${{ steps.yarnCache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-build-cache-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
working-directory: ts
run: yarn install
Expand All @@ -47,15 +45,6 @@ jobs:
- name: Build JS
working-directory: ts
run: yarn build
- name: Check changes
# https://unix.stackexchange.com/questions/155046/determine-if-git-working-directory-is-clean-from-a-script
run: |
if output=$(git status --porcelain) && [ -z "$output" ]; then
echo OK
else
echo Building the JS caused changes that has to be committed and pushed manually.
exit 1
fi

Python:
name: Python ${{ matrix.python }}, OctoPrint ${{ matrix.octoprint }}
Expand All @@ -81,11 +70,9 @@ jobs:
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip modules
uses: actions/cache@v3
env:
cache-name: cache-pip
with:
path: ${{ steps.pipCache.outputs.dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-python-${{ matrix.python }}-octoprint-${{ matrix.octoprint}}
key: ${{ runner.os }}-build-cache-pip-python-${{ matrix.python }}-octoprint-${{ matrix.octoprint}}
- name: Install OctoPrint
# see https://stackoverflow.com/questions/49854628/how-do-i-pip-install-the-latest-patch-number-of-a-package
run: pip install octoprint~=${{ matrix.octoprint }}.0
Expand All @@ -103,8 +90,8 @@ jobs:
- name: Report the coverage
working-directory: octoprint_octorelay
run: |
python -m coverage lcov --omit=test*
python -m coverage report --show-missing --omit=test*
python -m coverage lcov --omit=test*,_version*
python -m coverage report --show-missing --omit=test*,_version*
- name: Coveralls
uses: coverallsapp/github-action@v2
continue-on-error: true
Expand Down
125 changes: 125 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Release

on:
release:
types: [ published ]

jobs:
build:
name: Build the distribution
runs-on: ubuntu-latest
env:
NODE_VERSION: 18.x
PYTHON_VERSION: 3.11
OCTOPRINT_VERSION: 1.9
steps:
### UI
- name: Get yarn cache dir
id: yarnCache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v3
with:
path: ${{ steps.yarnCache.outputs.dir }}
key: ${{ runner.os }}-release-cache-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install UI dependencies
working-directory: ts
run: yarn install
- name: Build JS
working-directory: ts
run: yarn build
### Python
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Get pip cache dir
id: pipCache
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip modules
uses: actions/cache@v3
with:
path: ${{ steps.pipCache.outputs.dir }}
key: ${{ runner.os }}-release-cache-pip
- name: Install distribution dependencies
run: pip install --upgrade wheel setuptools pip
- name: Install OctoPrint
run: pip install octoprint~=${{ env.OCTOPRINT_VERSION }}.0
### Packing
- name: Build distribution package
run: python setup.py sdist --formats=zip
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist

integration:
name: Integration test on Python ${{ matrix.python }}, OctoPrint ${{ matrix.octoprint }}
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
octoprint: [ "1.8", "1.9" ]
exclude:
# These versions are not compatible to each other:
- python: 3.11
octoprint: 1.8
- python: 3.10
octoprint: 1.8
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Install OctoPrint
run: pip install octoprint~=${{ matrix.octoprint }}.0
- name: Install Wheel
# see https://community.octoprint.org/t/setuptools-error-while-installing-plugin-octoklipper-on-manual-op-installation/51387
if: matrix.octoprint == '1.8'
run: pip install wheel
- name: Install the distributed package
run: pip install dist/OctoRelay-*.zip

attach:
name: Attaching asset to the release
runs-on: ubuntu-latest
needs:
- build
- integration
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Rename to release.zip
run: cp dist/OctoRelay-*.zip release.zip
- name: Get release ID
id: get_release
uses: bruceadams/get-release@v1.3.2
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Attach the asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: release.zip
asset_name: release.zip
asset_content_type: application/zip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
__pycache__
OctoRelay.egg-info
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## Version 2

### 2.3.0

- Changing the release type to distributable package.
- Plugin version is now set automatically from GitHub release using `miniver`.
- A workflow creates a packages and attaches it as the release's asset.
- Thus, redundant files are removed from the distribution.
- The latest release distribution URL has changed to:

```
https://github.com/borisbu/OctoRelay/releases/download/latest/release.zip
```

### 2.2.4

- Fixed UI/UX bug.
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include README.md
include CHANGELOG.md
recursive-include octoprint_octorelay/templates *
recursive-include octoprint_octorelay/translations *
recursive-include octoprint_octorelay/static *
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Install via the bundled [Plugin Manager](https://docs.octoprint.org/en/master/bu
or manually using this URL:

```
https://github.com/borisbu/OctoRelay/archive/master.zip
https://github.com/borisbu/OctoRelay/releases/download/latest/release.zip
```

In case you want to enable the plugin for user groups other than admins and users (operators), you need to
Expand Down
2 changes: 2 additions & 0 deletions octoprint_octorelay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,5 @@ def input_polling(self):
"octoprint.comm.protocol.atcommand.sending":
__plugin_implementation__.process_at_command
}

from octoprint_octorelay._version import __version__
12 changes: 12 additions & 0 deletions octoprint_octorelay/_static_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# This file is part of 'miniver': https://github.com/jbweston/miniver
#
# This file will be overwritten by setup.py when a source or binary
# distribution is made. The magic value "__use_git__" is interpreted by
# version.py.

version = "__use_git__"

# These values are only set if the distribution was created with 'git archive'
refnames = "$Format:%D$"
git_hash = "$Format:%h$"
Loading