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

Auto diff for release #56

Merged
merged 2 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 14 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,29 @@ jobs:
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}

- name: Generate diff
run: |
make diff > diff.md

- name: Publish GitHub Release
if: github.event.inputs.target== 'PyPi'
env:
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
TITLE="${VERSION}"
DESCRIPTION="Generated for [AxoSyslog $(make print-axosyslog-version)]($(make print-axosyslog-release-url))."
TAG="${VERSION}"
TARBALL="dist/axosyslog_cfg_helper-${VERSION}.tar.gz"
LATEST_VERSION=$(curl -s https://api.github.com/repos/${{ github.repository_owner }}/axosyslog-cfg-helper/releases/latest | jq -r .tag_name)

echo "Generated for [AxoSyslog $(make print-axosyslog-version)]($(make print-axosyslog-release-url))." > description.md
echo -n "## [${LATEST_VERSION}](https://github.com/alltilla/axosyslog-cfg-helper/releases/tag/${LATEST_VERSION})" >> description.md
echo " -> [${VERSION}](https://github.com/alltilla/axosyslog-cfg-helper/releases/tag/${VERSION})" >> description.md
echo -e "\n\x60\x60\x60diff" >> description.md
cat diff.md >> description.md
echo -e "\x60\x60\x60" >> description.md

gh release create \
--title "${TITLE}" \
--notes "${DESCRIPTION}" \
--notes-file - \
"${TAG}" \
"${TARBALL}"
"${TARBALL}" < description.md
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ db: $(AXOSYSLOG_WORKING_DIR)
--source-dir=$(AXOSYSLOG_WORKING_DIR) \
--output=$(DATABASE_FILE)

diff:
@if [ -z "$(OUTPUT)" ]; then \
echo "OUTPUT must be set"; \
false; \
fi
@mkdir -p $(WORKING_DIR)
rm -rf $(WORKING_DIR)/axosyslog-cfg-helper-latest $(WORKING_DIR)/axosyslog-cfg-helper-latest.tar.gz
wget -q \
$(shell curl -s https://api.github.com/repos/alltilla/axosyslog-cfg-helper/releases/latest | jq -r '.assets[] | select(.name | contains ("tar.gz")) | .browser_download_url') \
-O $(WORKING_DIR)/axosyslog-cfg-helper-latest.tar.gz
mkdir -p $(WORKING_DIR)/axosyslog-cfg-helper-latest
tar -xz \
-f $(WORKING_DIR)/axosyslog-cfg-helper-latest.tar.gz \
-C $(WORKING_DIR)/axosyslog-cfg-helper-latest \
--strip-components=1
poetry run python axosyslog_cfg_helper/generate_diff.py \
-o $(WORKING_DIR)/axosyslog-cfg-helper-latest/axosyslog_cfg_helper/axosyslog-cfg-helper.db \
-n $(DATABASE_FILE) > $(OUTPUT)

package: db
poetry build

Expand Down
Loading