Skip to content

Commit

Permalink
Merge pull request #3229 from the-events-calendar/repo-sync/actions/m…
Browse files Browse the repository at this point in the history
…aster

🔄 synced file(s) with the-events-calendar/actions
  • Loading branch information
dpanta94 authored Sep 10, 2024
2 parents e39c55f + 539248c commit 505a728
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ on:
- 'src/modules/**.js'
- 'src/resources/js/**.js'
- 'src/resources/postcss/**.pcss'
- '.github/**/*'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: recursive
Expand Down
35 changes: 31 additions & 4 deletions bin/process-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,34 @@ CURRENT_VERSION=${2-}
ACTION_TYPE=${3-generate}
RELEASE_DATE=${4-today}

RELEASE_DATE=$( date "+%Y-%m-%d" -d "$RELEASE_DATE" ) # Release date formatted as YYYY-MM-DD
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS with gdate
RELEASE_DATE=$( gdate "+%Y-%m-%d" -d "$RELEASE_DATE" )
else
# Linux
RELEASE_DATE=$( date "+%Y-%m-%d" -d "$RELEASE_DATE" )
fi

sed_compatible() {
if [[ "$1" == "-r" ]]; then
# Remove the -r argument
shift
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS with -E flag
sed -i '' -E "$@"
else
# Linux with -r flag
sed -i -r "$@"
fi
else
# No -r argument, regular sed command
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
fi
}

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

Expand All @@ -14,7 +41,7 @@ cd $SCRIPT_DIR/../
echo "RELEASE_DATE=$RELEASE_DATE"

if [ "$ACTION_TYPE" == "amend-version" ]; then
perl -i -pe "s/^### \[\Q$CURRENT_VERSION\E\] .*$/### [$RELEASE_VERSION] $RELEASE_DATE/" changelog.md
sed_compatible "s/^### \[$CURRENT_VERSION\] .*$/### [$RELEASE_VERSION] $RELEASE_DATE/" changelog.md
else
if [ "$ACTION_TYPE" == "generate" ]; then
CHANGELOG_FLAG=""
Expand All @@ -38,11 +65,11 @@ CHANGELOG=${CHANGELOG//&/\\&}
echo "CHANGELOG=$CHANGELOG"

if [ "$ACTION_TYPE" == "amend-version" ]; then
perl -i -pe "s/^= \[\Q$CURRENT_VERSION\E\] .* =$/= [$RELEASE_VERSION] $RELEASE_DATE =/" readme.txt
sed_compatible "s/^= \[$CURRENT_VERSION\] .* =$/= [$RELEASE_VERSION] $RELEASE_DATE =/" readme.txt
else
if [ "$ACTION_TYPE" == "amend" ]; then
perl -i -p0e "s/= \[$RELEASE_VERSION\].*? =(.*?)(\n){2}(?==)//s" readme.txt # Delete the existing changelog for the release version first
fi

perl -i -pe "s/(== Changelog ==)/\1\n\n= [$RELEASE_VERSION] $RELEASE_DATE =\n\n$CHANGELOG/" readme.txt
sed_compatible -r "s|(== Changelog ==)|\1\n\n= [$RELEASE_VERSION] $RELEASE_DATE =\n\n$CHANGELOG|" readme.txt
fi
2 changes: 1 addition & 1 deletion common

0 comments on commit 505a728

Please sign in to comment.