4 Commits

Author SHA1 Message Date
8c5dc166ef chore(lock): update dependencies to latest versions
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 3s
Auto Changelog & Release / release (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Successful in 7s
2025-05-30 12:42:46 +02:00
63002a7f21 feat(cli): add validation for command options 2025-05-30 12:42:37 +02:00
5510ab74d6 feat(validation): add CLI validation helpers for input checks
- Introduce functions to validate CLI inputs like paths, identifiers, and environment variables
- Add error messages for invalid inputs to support user feedback
- Include unit tests to ensure correctness and robustness of validation logic
2025-05-30 12:42:25 +02:00
5d3afd30bd feat(build): add run permissions to compiled binaries 2025-05-30 12:42:00 +02:00
7 changed files with 235 additions and 115 deletions

View File

@@ -7,13 +7,217 @@ on:
- "**" - "**"
jobs: jobs:
release: detect-version-change:
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.set.outputs.version_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if VERSION file changed
if: github.ref == 'refs/heads/main'
run: |
echo "🔍 Vergleich mit github.event.before:"
echo "Before: ${{ github.event.before }}"
echo "After: ${{ github.sha }}"
echo "📄 Changed files between before and after:"
git diff --name-only ${{ github.event.before }} ${{ github.sha }} || echo "(diff failed)"
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '^VERSION$'; then
echo "✅ VERSION file was changed"
echo "VERSION_CHANGED=true" >> $GITHUB_ENV
else
echo "ℹ️ VERSION file not changed"
echo "VERSION_CHANGED=false" >> $GITHUB_ENV
fi
- name: Set output (always)
id: set
run: |
echo "version_changed=${VERSION_CHANGED:-false}" >> $GITHUB_OUTPUT
changelog-only:
needs: detect-version-change
if: github.ref != 'refs/heads/main' || needs.detect-version-change.outputs.version_changed == 'false'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Release
uses: https://git.0xmax42.io/actions/auto-changelog-release-action@v0 - name: Set Git Author
run: |
git config user.name "$CI_COMMIT_AUTHOR_NAME"
git config user.email "$CI_COMMIT_AUTHOR_EMAIL"
- name: Read CLIFF_VERSION from cliff.toml
id: cliff_version
run: |
echo "version=$(awk -F '=' '/^# CLIFF_VERSION=/ { gsub(/[" ]/, "", $2); print $2 }' cliff.toml)" >> $GITHUB_OUTPUT
- name: Restore git-cliff cache
id: restore-cliff
uses: https://git.0xmax42.io/actions/cache@v1
with: with:
token: ${{ secrets.RELEASE_PUBLISH_TOKEN }} key: cargo-cliff-${{ steps.cliff_version.outputs.version }}
paths: |
/root/.cargo/bin
- name: Install git-cliff
if: steps.restore-cliff.outputs.cache-hit != 'true'
run: |
cargo install git-cliff --version "${{ steps.cliff_version.outputs.version }}" --features gitea
- name: Generate unreleased changelog (if file exists or on main)
run: |
if [[ -f CHANGELOG.md || "${GITHUB_REF##refs/heads/}" == "main" ]]; then
echo "Generating CHANGELOG.md..."
git-cliff -c cliff.toml -o CHANGELOG.md
else
echo "CHANGELOG.md does not exist and this is not 'main'. Skipping generation."
fi
- name: Commit updated CHANGELOG
run: |
git add CHANGELOG.md
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "chore(changelog): update unreleased changelog"
git push origin "${GITHUB_REF##refs/heads/}"
fi
release:
needs: detect-version-change
if: needs.detect-version-change.outputs.version_changed == 'true' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Git Author
run: |
git config user.name "$CI_COMMIT_AUTHOR_NAME"
git config user.email "$CI_COMMIT_AUTHOR_EMAIL"
- name: Read VERSION
id: version
run: echo "value=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: Read CLIFF_VERSION from cliff.toml
id: cliff_version
run: |
echo "version=$(awk -F '=' '/^# CLIFF_VERSION=/ { gsub(/[" ]/, "", $2); print $2 }' cliff.toml)" >> $GITHUB_OUTPUT
- name: Restore git-cliff cache
id: restore-cliff
uses: https://git.0xmax42.io/actions/cache@v1
with:
key: cargo-cliff-${{ steps.cliff_version.outputs.version }}
paths: |
/root/.cargo/bin
- name: Install git-cliff
if: steps.restore-cliff.outputs.cache-hit != 'true'
run: |
cargo install git-cliff --version "${{ steps.cliff_version.outputs.version }}" --features gitea
- name: Generate changelog for release and tag
id: generate-changelog
run: |
VERSION=${{ steps.version.outputs.value }}
git-cliff -c cliff.toml -t "v$VERSION" -o CHANGELOG.md
BODY=$(mktemp)
ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g')
awk -v ver="$ESCAPED_VERSION" '
$0 ~ "^## \\[" ver "\\]" {
print_flag=1
line = $0
sub(/^## /, "", line)
sub(/\\s*\\(.*\\)/, "", line) # entfernt z. B. "(...)" oder "(*)"
print line
next
}
$0 ~ "^## \\[" && $0 !~ "^## \\[" ver "\\]" {
print_flag=0
}
print_flag
' CHANGELOG.md > "$BODY"
echo "changelog_body_path=$BODY" >> $GITHUB_OUTPUT
- name: Commit updated CHANGELOG
run: |
git add CHANGELOG.md
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "chore(changelog): update changelog for v${{ steps.version.outputs.value }}"
git push origin main
fi
- name: Create Git tag (if not exists)
run: |
VERSION=${{ steps.version.outputs.value }}
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists, skipping tag creation."
else
export GIT_AUTHOR_DATE="$(date --iso-8601=seconds)"
export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
git tag -a "v$VERSION" -F "${{ steps.generate-changelog.outputs.changelog_body_path }}" --cleanup=verbatim
git push origin "v$VERSION"
fi
- name: Create Gitea release
env:
RELEASE_PUBLISH_TOKEN: ${{ secrets.RELEASE_PUBLISH_TOKEN }}
run: |
VERSION=${{ steps.version.outputs.value }}
BODY_FILE="${{ steps.generate-changelog.outputs.changelog_body_path }}"
OWNER=$(echo "$GITHUB_REPOSITORY" | cut -d/ -f1)
REPO=$(echo "$GITHUB_REPOSITORY" | cut -d/ -f2)
# Token-Auswahl
TOKEN="${RELEASE_PUBLISH_TOKEN:-$ACTIONS_RUNTIME_TOKEN}"
if [[ -z "${RELEASE_PUBLISH_TOKEN:-}" ]]; then
echo "::warning title=Limited Release Propagation::"
echo "RELEASE_PUBLISH_TOKEN is not set. Using ACTIONS_RUNTIME_TOKEN instead."
echo "⚠️ Release events may not trigger other workflows if created with the runtime token."
echo
fi
# Prüfe, ob der Release schon existiert
if curl -sf "$GITHUB_API_URL/repos/$OWNER/$REPO/releases/tags/v$VERSION" \
-H "Authorization: token $TOKEN" > /dev/null; then
echo "🔁 Release for tag v$VERSION already exists, skipping."
exit 0
fi
echo "🚀 Creating Gitea release for v$VERSION"
# Release-Beschreibung vorbereiten
RELEASE_BODY=$(tail -n +2 "$BODY_FILE" | jq -Rs .)
curl -X POST "$GITHUB_API_URL/repos/$OWNER/$REPO/releases" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"tag_name": "v$VERSION",
"target_commitish": "main",
"name": "Release v$VERSION",
"body": $RELEASE_BODY,
"draft": false,
"prerelease": false
}
EOF
echo "✅ Release for tag $VERSION created successfully."

View File

@@ -43,22 +43,6 @@ jobs:
- name: Upload SHA256 for ${{ matrix.target }}-${{ matrix.arch }} - name: Upload SHA256 for ${{ matrix.target }}-${{ matrix.arch }}
run: .gitea/scripts/upload-asset.sh ./dist/systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.sha256 systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.sha256 run: .gitea/scripts/upload-asset.sh ./dist/systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.sha256 systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.sha256
- name: Create zstd compressed archive
run: |
FILE="./dist/systemd-timer-${{ matrix.target }}-${{ matrix.arch }}"
zstd -q -19 -T0 -f "$FILE" -o "$FILE.zst"
- name: Generate SHA256 for zstd compressed archive
run: |
FILE="./dist/systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.zst"
sha256sum "$FILE" > "$FILE.sha256"
- name: Upload zstd compressed archive for ${{ matrix.target }}-${{ matrix.arch }}
run: .gitea/scripts/upload-asset.sh ./dist/systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.zst systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.zst
- name: Upload SHA256 for zstd compressed archive
run: .gitea/scripts/upload-asset.sh ./dist/systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.zst.sha256 systemd-timer-${{ matrix.target }}-${{ matrix.arch }}.zst.sha256
- name: Run Releases Sync Action - name: Run Releases Sync Action
uses: https://git.0xmax42.io/actions/releases-sync@main uses: https://git.0xmax42.io/actions/releases-sync@main
with: with:

View File

@@ -2,38 +2,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.5.1](https://git.0xmax42.io/maxp/systemd-timer/compare/v0.5.0..v0.5.1) - 2025-06-15 ## [unreleased]
### 🚀 Features ### 🚀 Features
- *(install)* Add support for compressed .zst archives - ([3a1ee0c](https://git.0xmax42.io/maxp/systemd-timer/commit/3a1ee0cfd6ddba8734cde09196803e9ccdd14c5f))
- *(workflows)* Add zstd compression for build artifacts - ([d9183d2](https://git.0xmax42.io/maxp/systemd-timer/commit/d9183d2f04b03cbdaf9e11bf05f7ce66111123e5))
### 📚 Documentation
- *(readme)* Add input validation and multilingual support - ([ce78cf3](https://git.0xmax42.io/maxp/systemd-timer/commit/ce78cf3a9a14028114e0fb6fcc0973d86c2b2227))
### ⚙️ Miscellaneous Tasks
- *(workflows)* Simplify release workflow with auto-changelog - ([05f3b51](https://git.0xmax42.io/maxp/systemd-timer/commit/05f3b519f56d893a0135736d8b722302c7cdd3f6))
- *(workflows)* Add locked flag to cargo install for git-cliff - ([6efc151](https://git.0xmax42.io/maxp/systemd-timer/commit/6efc1515ed4f4fb8802405529e4a6e04870ec02a))
## [0.5.0](https://git.0xmax42.io/maxp/systemd-timer/compare/v0.4.1..v0.5.0) - 2025-05-30
### 🚀 Features
- *(cli)* Add validation for command options - ([1c07af4](https://git.0xmax42.io/maxp/systemd-timer/commit/1c07af402b35ba4c2abf89ff5816e791994db536))
- *(validation)* Add CLI validation helpers for input checks - ([3d95706](https://git.0xmax42.io/maxp/systemd-timer/commit/3d95706d683cac8d279dfb718541a17c42fa5d71))
- *(build)* Add run permissions to compiled binaries - ([ccb04e4](https://git.0xmax42.io/maxp/systemd-timer/commit/ccb04e49820ff8238d7e7ad853aab5db06d5dc8a))
- *(ci)* Add compile steps to CI workflow - ([531a02a](https://git.0xmax42.io/maxp/systemd-timer/commit/531a02a6e11a769f2e05888d49ea2b4808d974e3))
- *(vscode)* Add JSONC formatter configuration - ([c7af1fb](https://git.0xmax42.io/maxp/systemd-timer/commit/c7af1fb6caa46c22b84229745067d05bf60b6f64)) - *(vscode)* Add JSONC formatter configuration - ([c7af1fb](https://git.0xmax42.io/maxp/systemd-timer/commit/c7af1fb6caa46c22b84229745067d05bf60b6f64))
- *(i18n)* Support loading JSONC translation files - ([4ac5dd4](https://git.0xmax42.io/maxp/systemd-timer/commit/4ac5dd4c88324f99cb6827283ad85bb9718abbeb)) - *(i18n)* Support loading JSONC translation files - ([4ac5dd4](https://git.0xmax42.io/maxp/systemd-timer/commit/4ac5dd4c88324f99cb6827283ad85bb9718abbeb))
- *(config)* Add @std/jsonc dependency - ([8f1cb3f](https://git.0xmax42.io/maxp/systemd-timer/commit/8f1cb3fad71ead365d93087963ddb6c7202a9b4f)) - *(config)* Add @std/jsonc dependency - ([8f1cb3f](https://git.0xmax42.io/maxp/systemd-timer/commit/8f1cb3fad71ead365d93087963ddb6c7202a9b4f))
### 🐛 Bug Fixes
- *(build)* Update included files to use .jsonc format - ([f3f2c61](https://git.0xmax42.io/maxp/systemd-timer/commit/f3f2c61da0785dce4c6b8c7d8ef0ae9abf098172))
### 🎨 Styling ### 🎨 Styling
- *(i18n)* Add comments for clarity and rename files - ([5226269](https://git.0xmax42.io/maxp/systemd-timer/commit/5226269ec2a0b76dfa30ac8d614c3789ff3a837b)) - *(i18n)* Add comments for clarity and rename files - ([5226269](https://git.0xmax42.io/maxp/systemd-timer/commit/5226269ec2a0b76dfa30ac8d614c3789ff3a837b))
@@ -43,10 +19,6 @@ All notable changes to this project will be documented in this file.
- *(fs)* Update test descriptions and comments to English - ([c4f4614](https://git.0xmax42.io/maxp/systemd-timer/commit/c4f4614a2daee68f9b33b9676106214c65a1a427)) - *(fs)* Update test descriptions and comments to English - ([c4f4614](https://git.0xmax42.io/maxp/systemd-timer/commit/c4f4614a2daee68f9b33b9676106214c65a1a427))
- *(fs)* Add rollback tests for writeUnitFiles errors - ([6039d23](https://git.0xmax42.io/maxp/systemd-timer/commit/6039d236eb7de449ce22b1d9ea718389a3e2261d)) - *(fs)* Add rollback tests for writeUnitFiles errors - ([6039d23](https://git.0xmax42.io/maxp/systemd-timer/commit/6039d236eb7de449ce22b1d9ea718389a3e2261d))
### ⚙️ Miscellaneous Tasks
- *(lock)* Update dependencies to latest versions - ([28b23cf](https://git.0xmax42.io/maxp/systemd-timer/commit/28b23cf947ecc57eb7fde541b29c68b41e508e7d))
## [0.4.1](https://git.0xmax42.io/maxp/systemd-timer/compare/v0.4.0..v0.4.1) - 2025-05-28 ## [0.4.1](https://git.0xmax42.io/maxp/systemd-timer/compare/v0.4.0..v0.4.1) - 2025-05-28
### 🐛 Bug Fixes ### 🐛 Bug Fixes

View File

@@ -23,9 +23,6 @@ Ein einfaches CLI-Tool zum schnellen Erzeugen von systemd `.service` und `.timer
- `--cwd`: Arbeitsverzeichnis des Prozesses (`WorkingDirectory`) - `--cwd`: Arbeitsverzeichnis des Prozesses (`WorkingDirectory`)
- `--dry-run`: Gibt nur die generierten Inhalte aus, ohne sie zu schreiben - `--dry-run`: Gibt nur die generierten Inhalte aus, ohne sie zu schreiben
- Getestet und typisiert mit **Deno** + **Cliffy** - Getestet und typisiert mit **Deno** + **Cliffy**
- Eingaben werden validiert und auf Fehler geprüft;
- z.B. muss `--calendar` ein gültiger systemd `OnCalendar` Ausdruck sein
- Mehrsprachig (Englisch, Deutsch)
--- ---

View File

@@ -24,9 +24,6 @@ A simple CLI tool for quickly generating systemd `.service` and `.timer` units
* `--cwd`: Working directory for the process (`WorkingDirectory`) * `--cwd`: Working directory for the process (`WorkingDirectory`)
* `--dry-run`: Outputs unit content without writing to disk * `--dry-run`: Outputs unit content without writing to disk
* Tested and fully typed with **Deno** + **Cliffy** * Tested and fully typed with **Deno** + **Cliffy**
* Inputs are validated and checked for errors;
* e.g., `--calendar` must be a valid systemd `OnCalendar` expression
* Multilingual (English, German)
--- ---

View File

@@ -1 +1 @@
0.5.1 0.4.1

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Fail-safe bash mode # Fail-safe bash mode (only if bash is used)
if [ -n "$BASH_VERSION" ]; then if [ -n "$BASH_VERSION" ]; then
set -euo pipefail set -euo pipefail
else else
@@ -26,71 +26,37 @@ case "$OS" in
*) echo "Unsupported OS: $OS" >&2; exit 1 ;; *) echo "Unsupported OS: $OS" >&2; exit 1 ;;
esac esac
# === Datei- und URL-Namen === # === Download-URL zusammensetzen ===
BASE_NAME="${BINARY_NAME}-${OS}-${ARCH}" BINARY_FILE="${BINARY_NAME}-${OS}-${ARCH}"
ZST_NAME="${BASE_NAME}.zst" DOWNLOAD_URL="${REPO_URL}/${BINARY_FILE}"
ZST_URL="${REPO_URL}/${ZST_NAME}"
BIN_URL="${REPO_URL}/${BASE_NAME}"
echo "📦 Installing ${BINARY_NAME} for ${OS}/${ARCH}..." echo "📦 Installing ${BINARY_NAME} for ${OS}/${ARCH}..."
echo "🌐 Downloading from: ${DOWNLOAD_URL}"
USE_ZSTD=false # === Binary herunterladen ===
if command -v zstd >/dev/null; then TMP_FILE=$(mktemp)
echo "✅ 'zstd' found – will use compressed .zst archive" curl -fsSL "${DOWNLOAD_URL}" -o "${TMP_FILE}"
USE_ZSTD=true chmod +x "${TMP_FILE}"
fi
TMP_DIR=$(mktemp -d) # === SHA256-Check ===
cleanup() { TMP_HASH=$(mktemp)
rm -rf "$TMP_DIR" curl -fsSL "${DOWNLOAD_URL}.sha256" -o "$TMP_HASH"
} EXPECTED_HASH=$(cut -d ' ' -f1 "$TMP_HASH")
trap cleanup EXIT ACTUAL_HASH=$(openssl dgst -sha256 "$TMP_FILE" | awk '{print $2}')
if [ "$USE_ZSTD" = true ]; then if [ "$EXPECTED_HASH" != "$ACTUAL_HASH" ]; then
echo "🌐 Downloading: ${ZST_URL}"
curl -fsSL "$ZST_URL" -o "$TMP_DIR/${ZST_NAME}"
echo "🌐 Downloading checksum: ${ZST_URL}.sha256"
curl -fsSL "$ZST_URL.sha256" -o "$TMP_DIR/zst.sha256"
EXPECTED_HASH=$(cut -d ' ' -f1 "$TMP_DIR/zst.sha256")
ACTUAL_HASH=$(openssl dgst -sha256 "$TMP_DIR/${ZST_NAME}" | awk '{print $2}')
if [ "$EXPECTED_HASH" != "$ACTUAL_HASH" ]; then
echo "⚠️ Checksum mismatch for .zst archive!"
echo "Expected: $EXPECTED_HASH"
echo "Actual: $ACTUAL_HASH"
exit 1
fi
echo "📥 Decompressing..."
zstd -d -q "$TMP_DIR/${ZST_NAME}" -o "$TMP_DIR/${BASE_NAME}"
TMP_FILE="$TMP_DIR/${BASE_NAME}"
else
echo "🌐 Downloading uncompressed binary: ${BIN_URL}"
curl -fsSL "$BIN_URL" -o "$TMP_DIR/${BASE_NAME}"
echo "🌐 Downloading checksum: ${BIN_URL}.sha256"
curl -fsSL "$BIN_URL.sha256" -o "$TMP_DIR/binary.sha256"
EXPECTED_HASH=$(cut -d ' ' -f1 "$TMP_DIR/binary.sha256")
ACTUAL_HASH=$(openssl dgst -sha256 "$TMP_DIR/${BASE_NAME}" | awk '{print $2}')
if [ "$EXPECTED_HASH" != "$ACTUAL_HASH" ]; then
echo "⚠️ Checksum mismatch!" echo "⚠️ Checksum mismatch!"
echo "Expected: $EXPECTED_HASH" echo "Expected: $EXPECTED_HASH"
echo "Actual: $ACTUAL_HASH" echo "Actual: $ACTUAL_HASH"
exit 1 exit 1
fi
TMP_FILE="$TMP_DIR/${BASE_NAME}"
fi fi
chmod +x "$TMP_FILE" # === Installation ===
echo "🚀 Installing to ${INSTALL_PATH}/${BINARY_NAME}" echo "🚀 Installing to ${INSTALL_PATH}/${BINARY_NAME}"
if [ -w "$INSTALL_PATH" ]; then if [ -w "$INSTALL_PATH" ]; then
install -m 755 "$TMP_FILE" "${INSTALL_PATH}/${BINARY_NAME}" install -m 755 "${TMP_FILE}" "${INSTALL_PATH}/${BINARY_NAME}"
else else
sudo install -m 755 "$TMP_FILE" "${INSTALL_PATH}/${BINARY_NAME}" sudo install -m 755 "${TMP_FILE}" "${INSTALL_PATH}/${BINARY_NAME}"
fi fi
echo "✅ Installation complete: $(command -v ${BINARY_NAME})" echo "✅ Installation complete: $(command -v ${BINARY_NAME})"