mirror of
https://github.com/ivuorinen/actions.git
synced 2026-02-18 03:48:55 +00:00
fix: local references, release workflow (#301)
* fix: local references, release workflow * chore: apply cr comments
This commit is contained in:
44
action-versioning/README.md
Normal file
44
action-versioning/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# ivuorinen/actions/action-versioning
|
||||
|
||||
## Action Versioning
|
||||
|
||||
### Description
|
||||
|
||||
Automatically update SHA-pinned action references to match latest version tags
|
||||
|
||||
### Inputs
|
||||
|
||||
| name | description | required | default |
|
||||
|-----------------|------------------------------------------------|----------|---------|
|
||||
| `major-version` | <p>Major version tag to sync (e.g., v2025)</p> | `true` | `""` |
|
||||
| `token` | <p>GitHub token for authentication</p> | `false` | `""` |
|
||||
|
||||
### Outputs
|
||||
|
||||
| name | description |
|
||||
|---------------------|------------------------------------------------------------|
|
||||
| `updated` | <p>Whether action references were updated (true/false)</p> |
|
||||
| `commit-sha` | <p>SHA of the commit that was created (if any)</p> |
|
||||
| `needs-annual-bump` | <p>Whether annual version bump is needed (true/false)</p> |
|
||||
|
||||
### Runs
|
||||
|
||||
This action is a `composite` action.
|
||||
|
||||
### Usage
|
||||
|
||||
```yaml
|
||||
- uses: ivuorinen/actions/action-versioning@main
|
||||
with:
|
||||
major-version:
|
||||
# Major version tag to sync (e.g., v2025)
|
||||
#
|
||||
# Required: true
|
||||
# Default: ""
|
||||
|
||||
token:
|
||||
# GitHub token for authentication
|
||||
#
|
||||
# Required: false
|
||||
# Default: ""
|
||||
```
|
||||
165
action-versioning/action.yml
Normal file
165
action-versioning/action.yml
Normal file
@@ -0,0 +1,165 @@
|
||||
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
|
||||
# permissions:
|
||||
# - contents: write # Required for creating commits
|
||||
---
|
||||
name: Action Versioning
|
||||
description: 'Automatically update SHA-pinned action references to match latest version tags'
|
||||
author: 'Ismo Vuorinen'
|
||||
|
||||
branding:
|
||||
icon: git-commit
|
||||
color: blue
|
||||
|
||||
inputs:
|
||||
major-version:
|
||||
description: 'Major version tag to sync (e.g., v2025)'
|
||||
required: true
|
||||
token:
|
||||
description: 'GitHub token for authentication'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
outputs:
|
||||
updated:
|
||||
description: 'Whether action references were updated (true/false)'
|
||||
value: ${{ steps.check-update.outputs.updated }}
|
||||
commit-sha:
|
||||
description: 'SHA of the commit that was created (if any)'
|
||||
value: ${{ steps.commit.outputs.sha }}
|
||||
needs-annual-bump:
|
||||
description: 'Whether annual version bump is needed (true/false)'
|
||||
value: ${{ steps.check-year.outputs.needs-bump }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
with:
|
||||
token: ${{ inputs.token || github.token }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Check Current Year
|
||||
id: check-year
|
||||
shell: sh
|
||||
env:
|
||||
MAJOR_VERSION: ${{ inputs.major-version }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
current_year=$(date +%Y)
|
||||
version_year="${MAJOR_VERSION#v}"
|
||||
|
||||
if [ "$version_year" != "$current_year" ]; then
|
||||
echo "::warning::Annual version bump needed: $MAJOR_VERSION -> v$current_year"
|
||||
printf '%s\n' "needs-bump=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
printf '%s\n' "needs-bump=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Fetch Version Tag SHA
|
||||
id: fetch-sha
|
||||
shell: sh
|
||||
env:
|
||||
MAJOR_VERSION: ${{ inputs.major-version }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
# Fetch all tags
|
||||
git fetch --tags --force
|
||||
|
||||
# Get SHA for the major version tag
|
||||
if ! tag_sha=$(git rev-list -n 1 "$MAJOR_VERSION" 2>/dev/null); then
|
||||
echo "::error::Tag $MAJOR_VERSION not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf '%s\n' "tag-sha=$tag_sha" >> "$GITHUB_OUTPUT"
|
||||
echo "Tag $MAJOR_VERSION points to: $tag_sha"
|
||||
|
||||
- name: Check if Update Needed
|
||||
id: check-update
|
||||
shell: sh
|
||||
env:
|
||||
TAG_SHA: ${{ steps.fetch-sha.outputs.tag-sha }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
# Find all action references and check if any don't match the tag SHA
|
||||
needs_update=false
|
||||
|
||||
# Create temp file for action references
|
||||
temp_file=$(mktemp)
|
||||
trap 'rm -f "$temp_file"' EXIT
|
||||
|
||||
find . -maxdepth 2 -name "action.yml" -path "*/action.yml" ! -path "./_*" ! -path "./.github/*" -exec grep -h "uses: ivuorinen/actions/" {} \; > "$temp_file"
|
||||
|
||||
while IFS= read -r line; do
|
||||
current_sha=$(echo "$line" | grep -oE '@[a-f0-9]{40}' | sed 's/@//')
|
||||
|
||||
if [ "$current_sha" != "$TAG_SHA" ]; then
|
||||
echo "Found outdated reference: $current_sha (should be $TAG_SHA)"
|
||||
needs_update=true
|
||||
fi
|
||||
done < "$temp_file"
|
||||
|
||||
if [ "$needs_update" = "true" ]; then
|
||||
printf '%s\n' "updated=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Update needed - references are outdated"
|
||||
else
|
||||
printf '%s\n' "updated=false" >> "$GITHUB_OUTPUT"
|
||||
echo "No update needed - all references are current"
|
||||
fi
|
||||
|
||||
- name: Update Action References
|
||||
if: steps.check-update.outputs.updated == 'true'
|
||||
shell: sh
|
||||
env:
|
||||
TAG_SHA: ${{ steps.fetch-sha.outputs.tag-sha }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
echo "Updating all action references to SHA: $TAG_SHA"
|
||||
|
||||
# Update all action.yml files (excluding tests and .github)
|
||||
# Use .bak extension for cross-platform sed compatibility
|
||||
find . -maxdepth 2 -name "action.yml" -path "*/action.yml" ! -path "./_*" ! -path "./.github/*" -exec sed -i.bak \
|
||||
"s|ivuorinen/actions/\([a-z-]*\)@[a-f0-9]\{40\}|ivuorinen/actions/\1@$TAG_SHA|g" {} \;
|
||||
|
||||
# Remove backup files
|
||||
find . -maxdepth 2 -name "action.yml.bak" -path "*/action.yml.bak" ! -path "./_*" ! -path "./.github/*" -delete
|
||||
|
||||
echo "Action references updated successfully"
|
||||
|
||||
- name: Commit Changes
|
||||
if: steps.check-update.outputs.updated == 'true'
|
||||
id: commit
|
||||
shell: sh
|
||||
env:
|
||||
MAJOR_VERSION: ${{ inputs.major-version }}
|
||||
TAG_SHA: ${{ steps.fetch-sha.outputs.tag-sha }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git add -- */action.yml
|
||||
|
||||
if git diff --staged --quiet; then
|
||||
echo "No changes to commit"
|
||||
printf '%s\n' "sha=" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
git commit -m "chore: update action references to $MAJOR_VERSION ($TAG_SHA)" \
|
||||
-m "" \
|
||||
-m "This commit updates all internal action references to point to the latest" \
|
||||
-m "$MAJOR_VERSION tag SHA." \
|
||||
-m "" \
|
||||
-m "🤖 Generated with [Claude Code](https://claude.com/claude-code)" \
|
||||
-m "" \
|
||||
-m "Co-Authored-By: Claude <noreply@anthropic.com>"
|
||||
|
||||
commit_sha=$(git rev-parse HEAD)
|
||||
printf '%s\n' "sha=$commit_sha" >> "$GITHUB_OUTPUT"
|
||||
echo "Created commit: $commit_sha"
|
||||
fi
|
||||
37
action-versioning/rules.yml
Normal file
37
action-versioning/rules.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
# Validation rules for action-versioning action
|
||||
# Generated by update-validators.py v1.0.0 - DO NOT EDIT MANUALLY
|
||||
# Schema version: 1.0
|
||||
# Coverage: 100% (2/2 inputs)
|
||||
#
|
||||
# This file defines validation rules for the action-versioning GitHub Action.
|
||||
# Rules are automatically applied by validate-inputs action when this
|
||||
# action is used.
|
||||
#
|
||||
|
||||
schema_version: '1.0'
|
||||
action: action-versioning
|
||||
description: Automatically update SHA-pinned action references to match latest version tags
|
||||
generator_version: 1.0.0
|
||||
required_inputs:
|
||||
- major-version
|
||||
optional_inputs:
|
||||
- token
|
||||
conventions:
|
||||
major-version: semantic_version
|
||||
token: github_token
|
||||
overrides: {}
|
||||
statistics:
|
||||
total_inputs: 2
|
||||
validated_inputs: 2
|
||||
skipped_inputs: 0
|
||||
coverage_percentage: 100
|
||||
validation_coverage: 100
|
||||
auto_detected: true
|
||||
manual_review_required: false
|
||||
quality_indicators:
|
||||
has_required_inputs: true
|
||||
has_token_validation: true
|
||||
has_version_validation: true
|
||||
has_file_validation: false
|
||||
has_security_validation: true
|
||||
Reference in New Issue
Block a user