Skip to content

Commit

Permalink
fix(workflows): fix release, update changelog (#9)
Browse files Browse the repository at this point in the history
* fix(workflows/release): correct unset env DRY_RUN

* feat(workflows/release): add TAGS_FILE global

* fix(workflows/release): correct chagelog flag name

* misc: add tags.txt

* misc: newlines, rename var

* misc: newlines
  • Loading branch information
tcodes0 authored Sep 5, 2024
1 parent d32afc9 commit 1735457
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ jobs:
env:
CHANGELOG_FILE: CHANGELOG.md
BASH_ENV: ./lib.sh
DRY_RUN: false
run: ./workflows/release/tag.sh
2 changes: 2 additions & 0 deletions tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# this file is generated to aid in automating releases
v0.2.1
10 changes: 6 additions & 4 deletions workflows/release/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ validate() {
}

# Description: Calls changelog tool and updates CHANGELOG_FILE
# Globals : CHANGELOG_FILE (github workflow or .env)
# Args : 1=url 2=title 3=prefix
# Globals : CHANGELOG_FILE, TAGS_FILE (github workflow or .env)
# Args : 1=url 2=title 3=prefixes
# STDERR : Might print errors
# Returns : 1 if fail
# Sideeffects: Updates CHANGELOG_FILE
# Example : update_changelog pizza
update_changelog() {
local url=$1 title=${2:-} prefix=${3:-} changes changelog flags=()
local url=$1 title=${2:-} prefixes=${3:-} changes changelog flags=()

changelog=$(cat "$CHANGELOG_FILE")
flags+=(-title "$title")
flags+=(-tagprefix "$prefix")
flags+=(-tagprefixes "$prefixes")
flags+=(-url "$url")
flags+=(-tagsfile "${TAGS_FILE:-}")

changes=$(changelog "${flags[@]}")
if [ ! "$changes" ]; then
Expand All @@ -55,6 +56,7 @@ update_changelog() {
fi

printf %s "$changes" >"$CHANGELOG_FILE"
printf "\n\n" >>"$CHANGELOG_FILE"
printf %s "$changelog" >>"$CHANGELOG_FILE"
}

Expand Down
8 changes: 7 additions & 1 deletion workflows/release/tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,19 @@ validate_tags() {
}

# Description: Creates and pushes git tags
# Globals : DRY_RUN (set to echo to dry run)
# Globals : DRY_RUN bool
# Args : words separated by spaces
# STDOUT : Prints each tag created, plus git output
# STDERR : Git might output
# Sideeffects: Pushes git tags
# Example : tag_and_push foo/v1.1.1. bar/v1.2.3
tag_and_push() {
if [ "${DRY_RUN:-}" == "true" ]; then
DRY_RUN="echo"
else
DRY_RUN=""
fi

for tag in "$@"; do
msgln "$tag"
$DRY_RUN git tag "$tag" HEAD
Expand Down

0 comments on commit 1735457

Please sign in to comment.