Skip to content

Commit

Permalink
fix automatic snippet release
Browse files Browse the repository at this point in the history
  • Loading branch information
brainelectronics committed May 30, 2024
1 parent 53d662c commit 68766f7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@ jobs:
python -m pip install -U poetry twine
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install
- name: Update changelog with snippets
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets
- name: Parse changelog
id: parse_changelog
run: |
poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
poetry run changelog2version --changelog_file changelog.md.new --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
latest_version=$(poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
echo "latest_version=$latest_version" >> $GITHUB_ENV
- name: Build package
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets
poetry run changelog2version \
--changelog_file changelog.md.new \
--version_file snippets2changelog/version.py \
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@ jobs:
python -m pip install -U poetry twine
poetry self add "poetry-dynamic-versioning[plugin]"
poetry install
- name: Update changelog with snippets
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets
- name: Parse changelog
id: parse_changelog
run: |
poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
poetry run changelog2version --changelog_file changelog.md.new --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
latest_version=$(poetry run changelog2version --changelog_file changelog.md --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
echo "latest_version=$latest_version" >> $GITHUB_ENV
- name: Build package
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets
poetry run changelog2version \
--changelog_file changelog.md.new \
--version_file snippets2changelog/version.py \
Expand Down
17 changes: 17 additions & 0 deletions .snippets/5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Fix automatic snippet release
<!--
type: bugfix
scope: internal
affected: all
-->

### Added
- New `Update changelog with snippets` step in `release` and `test-release` workflow to create changelog before any onwards parsing steps
- Function `branch_name` of `snippets2changelog/collector.py` falls back to `return str(self._repo.head.commit.hexsha)` if in detached head mode

### Changed
- Set `fetch-depth: 0` to get all history for all branches and tags

### Fixed
- All GitHub workflows use `actions/checkout@v3`
- Parse new changelog file `changelog.md.new` in `test-release` and `release` workflow

0 comments on commit 68766f7

Please sign in to comment.