-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add publishing workflow and contribution instructions (#254)
* Publishing * Add branch condition to publish workflow * Wording * Remove usage of requirements.txt files * Add basepython resolution for numbered envs * Use uv in tox workflows * Unfinished publish workflow * trying stuff * Do not specify tox env in build workflow * Move pyinstaller dependency to tox * Actually run tox * Fix binary dist path * Revert incorrect binary path * Fix underscore in artifact name * verbose pypi * Use test pypi * Use `mreg-cli-v*` tag pattern * Dump workflow info * Add branch check * Try to create release * Try to use trusted publishing * Remove unused pypi vars * Try to rename binaries * Try to actually read actions docs * Fix bin name * Publish a4 * Rename binary after creation * Remove publishing branch * Make built binary executable * Remove executable step * Build on master and publish to real pypi * Update publishing instructions * Exit explicitly only on master branch * Add artifact and version info, move `-desc`to Removed * Final publishing test run * Enable master protection again * Make GitHub release non-prelease * Add missing newline * Fix CONTRIBUTING markdown lint violations Does not "fix" the ordered list rule violation, since indenting the code blocks looks very awkward.
- Loading branch information
Showing
6 changed files
with
201 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
name: build mreg-cli | ||
|
||
on: | ||
push: | ||
tags: | ||
- mreg-cli-v* | ||
|
||
concurrency: | ||
group: build-mreg-cli-${{ github.head_ref }} | ||
|
||
jobs: | ||
build_pypi: | ||
name: Build wheels and source distribution | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Exit if not on master branch | ||
if: github.ref_name != 'master' | ||
run: exit -1 | ||
|
||
- name: Install build dependencies | ||
run: python -m pip install --upgrade build | ||
|
||
- name: Build source distribution | ||
run: python -m build | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: pypi_artifacts | ||
path: dist/* | ||
if-no-files-found: error | ||
|
||
build_pyinstaller: | ||
name: Build pyinstaller binary | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, windows-latest, macos-latest] | ||
python-version: | ||
- '3.12' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Run PyInstaller with Tox | ||
run: | | ||
python -m ensurepip --upgrade | ||
python -m pip install tox tox-uv tox-gh-actions | ||
tox | ||
- name: Rename binary | ||
run: | | ||
mv dist/mreg-cli${{ contains(matrix.os, 'windows') && '.exe' || '' }} dist/mreg-cli-${{ matrix.os }}-${{ matrix.python-version }}${{ contains(matrix.os, 'windows') && '.exe' || '' }} | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: mreg-cli-${{ matrix.os }}-${{ matrix.python-version }}${{ contains(matrix.os, 'windows') && '.exe' || '' }} | ||
path: dist/mreg-cli-${{ matrix.os }}-${{ matrix.python-version }}${{ contains(matrix.os, 'windows') && '.exe' || '' }} | ||
if-no-files-found: error | ||
|
||
publish_pypi: | ||
name: Publish PyPI release | ||
needs: | ||
- build_pypi | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: pypi_artifacts | ||
path: dist | ||
|
||
- name: Push build artifacts to PyPI | ||
uses: pypa/[email protected] | ||
|
||
publish_github: | ||
name: Publish GitHub release | ||
needs: | ||
- build_pypi | ||
- build_pyinstaller | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Download PyInstaller binaries | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: mreg-cli-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- name: Download wheel and source distributions | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: pypi_artifacts | ||
path: dist | ||
merge-multiple: true | ||
|
||
- name: Create GitHub release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
Release notes for ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload release asset | ||
id: upload-release-asset | ||
uses: softprops/action-gh-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
files: dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
The big Pydantic update. The entire codebase has been rewritten to use Pydantic for request and response validation. This brings with it a huge improvement to the development experience and the robustness of the code. | ||
|
||
### Added | ||
|
||
- `--version` option to display current application version and exit. | ||
Version number is in the form of `major.minor.patch` if installed from a published version. | ||
Shows a version number including the commit hash if installed from a git repository in the form of `major.minor.patch.dev123+gabc1234`. | ||
See [Default versioning scheme](https://setuptools-scm.readthedocs.io/en/latest/usage/#default-versioning-scheme) in the [setuptools_scm](https://github.com/pypa/setuptools_scm/) documentation for more information. | ||
- The version can be accessed programmatically with `mreg_cli.__version__`. | ||
- `label set_description` command to set the description of a label. | ||
- `network list_excluded_ranges` command to list the excluded ranges of a network. | ||
- Application can now store tokens for multiple servers and will pick the correct one based on the server URL. | ||
- Building binaries for Windows, Linux and MacOS, and publishing the package to PyPI on each GitHub release. | ||
|
||
### Changed | ||
|
||
- The application now uses Pydantic internally to validate request and response data. This should make the code more robust and easier to maintain. | ||
- Application now attempts to send JSON for every request. This should improve the consistency of the API responses. | ||
- Version now follows Semantic Versioning 2.0.0 and is automatically determined based on the most recent git tag (`mreg-cli-v*`). As part of this change, the verison has been bumped from 0.9.10 to 1.0.0. See the Added section for more information on how version numbers are accessed. | ||
|
||
### Removed | ||
|
||
- `label rename -desc` option. Description modification is now done through the new `label set_description` command. | ||
|
||
### Fixed | ||
|
||
- Hopefully more than we broke. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Contributing | ||
|
||
If you would like to contribute to this project, please follow these steps: | ||
|
||
1. Fork the repository | ||
2. Create a new branch (`git checkout -b feature/branch-name`) | ||
3. Make changes | ||
4. Commit your changes (`git commit -am 'Add some feature'`) | ||
5. Push to the branch (`git push origin feature/branch-name`) | ||
6. Create a Pull Request | ||
|
||
## Publishing | ||
|
||
Publishing new versions is automatically handled by GitHub actions for versions tagged with `mreg-cli-v*` (e.g. `mreg-cli-v1.0.0`). If you are a maintainer, you can create a new release by following these steps: | ||
|
||
1. Switch to the `master` branch: | ||
|
||
```bash | ||
git checkout master | ||
``` | ||
|
||
2. Create a new tag: | ||
|
||
```bash | ||
git tag mreg-cli-v1.2.3 | ||
``` | ||
|
||
3. Push the tag to the upstream repository: | ||
|
||
```bash | ||
git push upstream mreg-cli-v1.2.3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters