mirror of
https://github.com/drewcassidy/yaclog.git
synced 2024-09-01 14:58:58 +00:00
Compare commits
4 Commits
d6da31b6ff
...
1f01bda2f4
Author | SHA1 | Date | |
---|---|---|---|
1f01bda2f4 | |||
629d931979 | |||
d2296fb926 | |||
80e35de136 |
16
.github/workflows/python-publish.yml
vendored
16
.github/workflows/python-publish.yml
vendored
@ -40,9 +40,9 @@ jobs:
|
|||||||
run: python -m unittest -v
|
run: python -m unittest -v
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: test
|
# needs: test
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -56,7 +56,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install setuptools wheel twine
|
python -m pip install setuptools wheel twine
|
||||||
python -m pip install . # Self hosting!
|
|
||||||
|
|
||||||
- name: Install pypa/build
|
- name: Install pypa/build
|
||||||
run: python -m pip install build --user
|
run: python -m pip install build --user
|
||||||
@ -64,10 +63,9 @@ jobs:
|
|||||||
- name: Build a binary wheel and source tarball
|
- name: Build a binary wheel and source tarball
|
||||||
run: python -m build --sdist --wheel --outdir dist/
|
run: python -m build --sdist --wheel --outdir dist/
|
||||||
|
|
||||||
- name: Get version name and body
|
- name: Get version info
|
||||||
run: |
|
id: yaclog-show
|
||||||
echo "VERSION_TILE=$(yaclog show -n)" >> $GITHUB_ENV
|
uses: ./
|
||||||
echo "$(yaclog show -mb)" >> RELEASE.md
|
|
||||||
|
|
||||||
- name: Publish to PyPI
|
- name: Publish to PyPI
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
@ -78,7 +76,7 @@ jobs:
|
|||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: dist/*
|
files: dist/*
|
||||||
name: ${{ env.VERSION_TITLE }}
|
name: ${{ steps.yaclog-show.outputs.name }}
|
||||||
body_path: RELEASE.md
|
body_path: ${{ steps.yaclog-show.outputs.body_file }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
87
action.yaml
Normal file
87
action.yaml
Normal 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
|
@ -72,9 +72,10 @@ def reformat(obj: Changelog):
|
|||||||
help='Show only the version 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, '
|
@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')
|
'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.argument('version_names', metavar='VERSIONS', type=str, nargs=-1)
|
||||||
@click.pass_obj
|
@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.
|
Show the changes for VERSIONS.
|
||||||
|
|
||||||
@ -110,6 +111,20 @@ def show(obj: Changelog, all_versions, markdown, mode, version_names):
|
|||||||
raise click.ClickException(str(v))
|
raise click.ClickException(str(v))
|
||||||
|
|
||||||
sep = '\n\n' if mode == 'body' or mode == 'full' else '\n'
|
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]))
|
click.echo(sep.join([str_func(v, kwargs) for v in versions]))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user