Skip to content
Open
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
13 changes: 10 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(ruby -r ./lib/gocardless_pro/version.rb -e 'puts GoCardlessPro::VERSION')
# Guard against a crafted version string reaching later shell commands.
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "Refusing to release: '$VERSION' is not a valid semantic version"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
if gh release view "v$VERSION" >/dev/null 2>&1; then
echo "already_published=true" >> $GITHUB_OUTPUT
Expand All @@ -80,8 +85,9 @@ jobs:
- name: Extract changelog notes for this version
id: notes
if: steps.version_check.outputs.already_published == 'false'
env:
VERSION: ${{ steps.version_check.outputs.version }}
run: |
VERSION="${{ steps.version_check.outputs.version }}"
NOTES=""
if [ -f CHANGELOG.md ]; then
NOTES=$(awk -v ver="$VERSION" '
Expand All @@ -100,9 +106,10 @@ jobs:
if: steps.version_check.outputs.already_published == 'false'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version_check.outputs.version }}
NOTES: ${{ steps.notes.outputs.notes }}
run: |
NOTES="${{ steps.notes.outputs.notes }}"
TAG="v${{ steps.version_check.outputs.version }}"
TAG="v${VERSION}"
if [ -n "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
gh release create "$TAG" --title "$TAG" --notes "$NOTES"
else
Expand Down