Skip to content

Commit

Permalink
Merge pull request #56 from alltilla/auto-diff-for-release
Browse files Browse the repository at this point in the history
Auto diff for release
  • Loading branch information
alltilla authored Nov 10, 2024
2 parents 66db436 + 5f73889 commit 8767b56
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
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

0 comments on commit 8767b56

Please sign in to comment.