Skip to content

Commit

Permalink
Add version check to release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pdil committed Mar 31, 2024
1 parent beee772 commit 903bb48
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflow-resources/release-version-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# assumes $INPUT_VERSION is set to the selected release version
CURRENT_VERSION=$(echo "$(cat DESCRIPTION)" | grep "Version:" | awk '{print $2}')

if [ "$(printf '%s\n' "$INPUT_VERSION" "$CURRENT_VERSION" | sort -V | head -n1)" = "$INPUT_VERSION" ]; then
echo "::error title=Invalid version::Provided version number must be higher than the current version ($CURRENT_VERSION)."
exit 1
fi
19 changes: 18 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

name: release
run-name: Release ${{ github.event.repository.name }} ${{ inputs.version }}

on:
workflow_dispatch:
Expand All @@ -8,6 +9,17 @@ on:
description: "Release version number (e.g. 1.0.2)"
required: true
type: string
# When calling this workflow from another repo, ensure the following files are
# located in the local .github/workflow-resources directory:
# • release-checklist.R
# • release-pr-body.md
# • release-version-check.sh
workflow_call:
inputs:
version:
description: "Release version number (e.g. 1.0.2)"
required: true
type: string

jobs:
release:
Expand All @@ -17,6 +29,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Check version number
env:
INPUT_VERSION: ${{ inputs.version }}
run: .github/workflow-resources/release-version-check.sh

- name: Setup R
uses: r-lib/actions/setup-r@v2

Expand Down Expand Up @@ -46,7 +63,7 @@ jobs:
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "[unreleased]"
replace: "usmapdata ${{ inputs.version }}"
replace: "${{ github.event.repository.name }} ${{ inputs.version }}"
include: "NEWS.md"
regex: false

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-map-data.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

name: update-map-data
run-name: Update map data

on:
schedule:
Expand Down

0 comments on commit 903bb48

Please sign in to comment.