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

fix(workflows): fix release, update changelog #9

Merged
merged 6 commits into from
Sep 5, 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
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
Loading