13 Commits

Author SHA1 Message Date
1f01bda2f4 dogfood own action 2024-08-20 00:28:48 -07:00
629d931979 Don't trample over existing python installs 2024-08-20 00:28:38 -07:00
d2296fb926 name and description 2024-08-19 23:31:42 -07:00
80e35de136 Add github action for getting version info and making releases 2024-08-19 23:30:45 -07:00
d6da31b6ff Release Version 1.3.0
### Added

- added a `--version` option to `yaclog show` that prints just the version number

### Changed

- removed support for Click 7 as a dependency
2024-08-08 00:51:31 -07:00
d4f477a544 Update build dependencies 2024-08-08 00:50:37 -07:00
a392f09a51 drop support for Click 7.0 2024-08-08 00:50:37 -07:00
683ccbf916 Bump actions/setup-python from 5.1.0 to 5.1.1
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.0 to 5.1.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5.1.0...v5.1.1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-08 00:44:10 -07:00
2a67f6edc7 Infer version number for unreleased versions
increment the patch number. not always whats intended but at least produces something unique
2024-08-08 00:43:16 -07:00
c4be5d2420 add "--version" option to yaclog show 2024-08-08 00:30:18 -07:00
30947769e1 Readthedocs broke their dang config schema? 2024-04-16 00:08:25 -07:00
6589a91d7e Update CI workflow some more 2024-04-16 00:03:35 -07:00
802633b9a7 Update CI workflow 2024-04-16 00:02:09 -07:00
6 changed files with 147 additions and 24 deletions

View File

@ -9,14 +9,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
click-version: [ "click~=7.0", "click~=8.0" ]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
click-version: [ "click~=8.0" ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.4.0
uses: actions/setup-python@v5.1.1
with:
python-version: ${{ matrix.python-version }}
@ -40,23 +40,22 @@ jobs:
run: python -m unittest -v
deploy:
needs: test
# needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4.4.0
uses: actions/setup-python@v5.1.1
with:
python-version: '3.x'
python-version: '>=3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine
python -m pip install . # Self hosting!
- name: Install pypa/build
run: python -m pip install build --user
@ -64,10 +63,9 @@ jobs:
- name: Build a binary wheel and source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Get version name and body
run: |
echo "VERSION_TILE=$(yaclog show -n)" >> $GITHUB_ENV
echo "$(yaclog show -mb)" >> RELEASE.md
- name: Get version info
id: yaclog-show
uses: ./
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
@ -75,10 +73,10 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Publish to Github
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
name: ${{ env.VERSION_TITLE }}
body_path: RELEASE.md
name: ${{ steps.yaclog-show.outputs.name }}
body_path: ${{ steps.yaclog-show.outputs.body_file }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -5,6 +5,12 @@
# Required
version: 2
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
@ -16,7 +22,6 @@ formats:
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- method: pip
path: .

View File

@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file
## Version 1.3.0 - 2024-08-08
### Added
- added a `--version` option to `yaclog show` that prints just the version number
### Changed
- removed support for Click 7 as a dependency
## Version 1.2.0 - 2024-04-16
### Added

87
action.yaml Normal file
View File

@ -0,0 +1,87 @@
name: 'Yaclog'
description: 'Get version information from a changelog, and optionally create a new release'
branding:
icon: file-text
color: blue
inputs:
markdown:
description: If outputs should be in markdown format or not
default: 'true'
release:
description: >
Creates a new release and commits it if set. Directly passed to the arguments of `yaclog release`.
Can be a version number or an increment tag like `--major`, `--minor`, or `--patch`.
The resulting commit and tag will be pushed back to the repo, but the workflow must have write permissions.
Add
```yaml
permissions:
contents: write
```
to your workflow to allow this.
outputs:
name:
description: "The current version name. For example, `Version 1.3.0`"
value: ${{ steps.yaclog-show.outputs.name}}
header:
description: "The entire header for the current version. For example, `Version 1.3.0 - 2024-08-08`"
value: ${{ steps.yaclog-show.outputs.header }}
version:
description: "The current version number. For example, `1.3.0`"
value: ${{ steps.yaclog-show.outputs.version }}
body_file:
description: "Path to a temporary file containing the version body"
value: ${{ steps.yaclog-show.outputs.body_file }}
changelog:
description: "Path to the entire changelog file."
value: ${{ steps.yaclog-show.outputs.changelog }}
runs:
using: "composite"
steps:
- id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'
update-environment: 'false'
- name: Setup Yaclog
shell: bash
run: |
${{ steps.setup-python.outputs.python-path }} -m pip install ${{ github.action_path }}
# now make it available in $PATH
# this whole rigamarole is because we are using a python root that isnt in $PATH as to not step over other actions
mkdir -p "$GITHUB_ACTION_PATH/bin"
echo '${{ steps.setup-python.outputs.python-path }} -m yaclog.cli $@' > "$GITHUB_ACTION_PATH/bin/yaclog"
chmod +x "$GITHUB_ACTION_PATH/bin/yaclog"
echo "$GITHUB_ACTION_PATH/bin" > "$GITHUB_PATH"
- name: Create New Release
shell: bash
if: ${{ inputs.release }}
run: yaclog release --yes --commit ${{ inputs.release }}
- name: Get Version Information
id: yaclog-show
shell: bash
run: |
yaclog show ---gh-actions ${{ inputs.markdown && '--markdown' }} >> "$GITHUB_OUTPUT"
# output like so:
# name=Version 1.3.0
# header=Version 1.3.0 - 2024-08-08
# version=1.3.0
# body_file={path to file containing version body}
# changelog={path to changelog}
- name: Push Changes
if: ${{ inputs.release }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git push
git push --tags

View File

@ -1,7 +1,7 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools_scm>=6.2",
"setuptools>=64",
"setuptools_scm>=8",
"wheel"
]
build-backend = "setuptools.build_meta"
@ -29,7 +29,7 @@ classifiers = [
requires-python = ">= 3.8"
dependencies = [
"Click >= 7.0",
"Click >= 8.0",
"GitPython >= 3",
"packaging >= 20",
"tomlkit >= 0.11"

View File

@ -70,9 +70,12 @@ def reformat(obj: Changelog):
help='Show only the version body.')
@click.option('--header', '-h', 'mode', flag_value='header',
help='Show only the version header.')
@click.option('--version', '-v', 'mode', flag_value='version', help='Show only the version number. If the current version is unreleased, '
'this is inferred by incrementing the patch number of the last released version')
@click.option('---gh-actions', 'gh_actions', is_flag=True, hidden=True)
@click.argument('version_names', metavar='VERSIONS', type=str, nargs=-1)
@click.pass_obj
def show(obj: Changelog, all_versions, markdown, mode, version_names):
def show(obj: Changelog, all_versions, markdown, mode, version_names, gh_actions):
"""
Show the changes for VERSIONS.
@ -84,15 +87,22 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
'name': (lambda v, k: v.name),
'body': (lambda v, k: v.body(**k)),
'header': (lambda v, k: v.header(**k)),
'version': (lambda v, k: str(v.version))
}
str_func = functions[mode]
kwargs = {'md': markdown, 'color': True}
try:
if all_versions:
versions = obj.versions
elif len(version_names) == 0:
versions = [obj.current_version()]
if mode == 'version' and versions[0].name == 'Unreleased':
latest = obj.current_version(released=True).version
inferred = yaclog.version.increment_version(str(latest), 2, '')
print(str(inferred))
return
else:
versions = [obj.get_version(name) for name in version_names]
except KeyError as k:
@ -100,9 +110,21 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
except ValueError as v:
raise click.ClickException(str(v))
kwargs = {'md': markdown, 'color': True}
sep = '\n\n' if mode == 'body' or mode == 'full' else '\n'
if gh_actions:
import tempfile
all_modes = [ 'name', 'header', 'version' ]
outputs = [f'{mode}={sep.join([functions[mode](v, kwargs) for v in versions])}' for mode in all_modes]
click.echo('\n'.join(outputs))
body_fd, body_file = tempfile.mkstemp(text=True)
with os.fdopen(body_fd, 'w') as f:
f.write(sep.join([functions['body'](v, kwargs) for v in versions]))
click.echo(f'body_file={body_file}')
click.echo(f'changelog={obj.path}')
return
click.echo(sep.join([str_func(v, kwargs) for v in versions]))