Skip to content
Draft
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
40 changes: 40 additions & 0 deletions .github/scripts/update-year.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -e

# Get current year
CURRENT_YEAR=$(date +%Y)

# Extract year from go.mod module path (portable across macOS and Linux)
MODULE_YEAR=$(grep 'module github.com/opslevel/opslevel-go/v' go.mod | sed -E 's/.*\/v([0-9]{4}).*/\1/' || echo "")

if [ -z "$MODULE_YEAR" ]; then
echo "Error: Could not extract year from go.mod module path"
exit 1
fi

echo "Current year: $CURRENT_YEAR"
echo "Module year: $MODULE_YEAR"

if [ "$MODULE_YEAR" == "$CURRENT_YEAR" ]; then
echo "Module year is already current. No updates needed."
exit 0
fi

echo "Updating module path from v$MODULE_YEAR to v$CURRENT_YEAR..."

# Update go.mod module path
sed -i "s|github.com/opslevel/opslevel-go/v$MODULE_YEAR|github.com/opslevel/opslevel-go/v$CURRENT_YEAR|g" go.mod

# Update all Go files (primarily test imports)
find . -name "*.go" -type f -exec sed -i "s|github.com/opslevel/opslevel-go/v$MODULE_YEAR|github.com/opslevel/opslevel-go/v$CURRENT_YEAR|g" {} +

# Update README.md
if [ -f README.md ]; then
sed -i "s|opslevel-go/v$MODULE_YEAR|opslevel-go/v$CURRENT_YEAR|g" README.md
fi

# Run go mod tidy to update go.sum
go mod tidy

echo "Year update complete: v$MODULE_YEAR -> v$CURRENT_YEAR"
echo "updated=true" >> $GITHUB_OUTPUT
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ jobs:
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Update Year if Needed
id: update_year
run: |
chmod +x .github/scripts/update-year.sh
.github/scripts/update-year.sh
- name: Commit Year Update
if: steps.update_year.outputs.updated == 'true'
run: |
git config user.name "OpsLevel Bots"
git config user.email "bots@opslevel.com"
CURRENT_YEAR=$(date +%Y)
git add .
git commit -m "Automated year update to v$CURRENT_YEAR"
git push origin HEAD
- name: Set Release Version
id: version
run: |
Expand Down