Skip to content

Fix reusable workflow configuration (#18) #12

Fix reusable workflow configuration (#18)

Fix reusable workflow configuration (#18) #12

Workflow file for this run

name: Create Release
on:
push:
branches:
- main
paths:
- 'sync-ssh-keys.sh'
- 'users.conf'
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from script
id: get_version
run: |
VERSION=$(awk -F'"' '/SCRIPT_VERSION/ {print $2; exit}' sync-ssh-keys.sh)
if [[ ! $VERSION =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
echo "Error: Invalid version format: $VERSION" >&2
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create tag if needed
run: |
TAG="v${{ steps.get_version.outputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists."
else
git config user.name "github-actions"
git config user.email "[email protected]"
git tag "$TAG"
git push origin "$TAG"
fi
- name: Create release zip
run: |
zip ssh-key-sync.zip sync-ssh-keys.sh users.conf
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
generate_release_notes: true
files: |
ssh-key-sync.zip
sync-ssh-keys.sh