changes actions to composite because packages are only private which is stupid and inane and shouldn't be that way like what the actual hell why can't they just make things logical
All checks were successful
Build and Push Deno Release Action / build-and-publish (push) Successful in 26s
Build and Push Version Check Action / build (push) Successful in 18s

This commit is contained in:
Emmaline Autumn 2025-05-06 22:07:43 -06:00
parent 92323d3829
commit a198601c34
3 changed files with 44 additions and 57 deletions

View File

@ -1,15 +1,22 @@
name: Deno Multi-Platform Release
description: Compile a Deno CLI tool for multiple platforms and attach to a Gitea release
description: Compile and attach binaries to a Gitea release
inputs:
entrypoint:
description: Path to the Deno entrypoint file (e.g., `src/main.ts`)
description: Deno entrypoint file (e.g., src/main.ts)
required: true
compile-flags:
description: Optional space-separated flags to pass to `deno compile`
description: Optional flags to pass to `deno compile`
required: false
runs:
using: "docker"
image: git.cyborggrizzly.com/bearmetal/ci-actions/deno-release:latest
args:
- ${{ inputs.entrypoint }}
- ${{ inputs.compile-flags }}
using: "composite"
steps:
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: 2.3.1
- name: Run release script
shell: bash
run: |
chmod +x ./deno-release/release.sh
./deno-release/release.sh "${{ inputs.entrypoint }}" "${{ inputs.compile-flags }}"

65
deno-release/entrypoint.sh Normal file → Executable file
View File

@ -32,20 +32,14 @@ for target in "${platforms[@]}"; do
"$ENTRYPOINT"
done
API_URL="${CI_SERVER_URL:-https://gitea.example.com}/api/v1"
RELEASE_ENDPOINT="$API_URL/repos/$OWNER_NAME/$REPO_NAME/releases"
# Get commits since the last tag
# Generate changelog
PREV_TAG=$(git describe --tags --abbrev=0 "$TAG_NAME"^ 2>/dev/null || echo "")
if [[ -n "$PREV_TAG" ]]; then
echo "Generating changelog from $PREV_TAG to $TAG_NAME"
COMMITS=$(git log "$PREV_TAG..$TAG_NAME" --pretty=format:"%s (%an)" --no-merges)
else
echo "No previous tag found, generating changelog from initial commit"
COMMITS=$(git log --pretty=format:"%s (%an)" --no-merges)
fi
# Group commits by type
CHANGELOG=""
append_section() {
local TYPE="$1"
@ -53,62 +47,40 @@ append_section() {
local EMOJI="$3"
local MATCHED=$(echo "$COMMITS" | grep -E "^${TYPE}: " || true)
if [[ -n "$MATCHED" ]]; then
CHANGELOG+="## $EMOJI $TITLE\\n"
CHANGELOG+="## $EMOJI $TITLE\n"
while IFS= read -r line; do
# Remove prefix (e.g., "feat: ")
local CLEANED=$(echo "$line" | sed -E "s/^${TYPE}: //")
CHANGELOG+="- $CLEANED\\n"
CHANGELOG+="- $CLEANED\n"
done <<< "$MATCHED"
CHANGELOG+="\\n"
CHANGELOG+="\n"
fi
}
append_section "feat" "Features" "✨"
append_section "fix" "Fixes" "🐛"
append_section "chore" "Chores" "🧹"
append_section "refactor" "Refactors" "🔧"
append_section "docs" "Documentation" "📝"
append_section "test" "Tests" "🧪"
append_section "style" "Style" "🎨"
append_section "ci" "CI/CD" "⚙️"
# Escape quotes for JSON
CHANGELOG_ESCAPED=$(printf "%s" "$CHANGELOG" | sed 's/"/\\"/g')
RELEASE_BODY=""
# Fallback if no commits found
[[ -z "$CHANGELOG" ]] && CHANGELOG="No commit history found."
# Inject into manual changelog if available
MANUAL_SECTION=""
if [[ -f "CHANGELOG.md" ]]; then
echo "Looking for manual changelog entry for $TAG_NAME..."
MANUAL_SECTION=$(awk "/^## \\[?$TAG_NAME\\]? /{flag=1; next} /^## /{flag=0} flag" CHANGELOG.md)
if [[ -n "$MANUAL_SECTION" ]]; then
echo "Manual entry found for $TAG_NAME"
if grep -q '<!-- auto-changelog -->' <<< "$MANUAL_SECTION"; then
echo "Injecting auto-changelog into manual entry"
FINAL_SECTION=$(sed "s|<!-- auto-changelog -->|$CHANGELOG|" <<< "$MANUAL_SECTION")
else
FINAL_SECTION="$MANUAL_SECTION"
fi
# Escape quotes and newlines
RELEASE_BODY=$(printf "%s" "$FINAL_SECTION" | sed ':a;N;$!ba;s/\n/\\n/g; s/"/\\"/g')
if [[ "$MANUAL_SECTION" == *"<!-- auto-changelog -->"* ]]; then
MANUAL_SECTION=$(echo "$MANUAL_SECTION" | sed "s|<!-- auto-changelog -->|$CHANGELOG|")
fi
fi
# Fallback to full auto-changelog
if [[ -z "$RELEASE_BODY" ]]; then
echo "Using full auto-generated changelog"
RELEASE_BODY="$CHANGELOG_ESCAPED"
fi
RELEASE_BODY="${MANUAL_SECTION:-$CHANGELOG}"
RELEASE_BODY_ESCAPED=$(printf "%s" "$RELEASE_BODY" | sed ':a;N;$!ba;s/\n/\\n/g; s/"/\\"/g')
# Determine prerelease
IS_PRERELEASE="false"
if [[ "$TAG_NAME" =~ -[0-9A-Za-z] ]]; then
IS_PRERELEASE="true"
fi
[[ "$TAG_NAME" =~ -[0-9A-Za-z] ]] && IS_PRERELEASE="true"
echo "Creating release $TAG_NAME (prerelease: $IS_PRERELEASE)..."
# Create release
API_URL="${CI_SERVER_URL:-https://git.cyborggrizzly.com}/api/v1"
RELEASE_ENDPOINT="$API_URL/repos/$OWNER_NAME/$REPO_NAME/releases"
RELEASE_JSON=$(curl -sS -X POST "$RELEASE_ENDPOINT" \
-H "Authorization: token $GITEA_TOKEN" \
@ -119,13 +91,12 @@ RELEASE_JSON=$(curl -sS -X POST "$RELEASE_ENDPOINT" \
"name": "$TAG_NAME",
"draft": false,
"prerelease": $IS_PRERELEASE,
"body": "$RELEASE_BODY"
"body": "$RELEASE_BODY_ESCAPED"
}
EOF
)
UPLOAD_URL=$(echo "$RELEASE_JSON" | jq -r '.upload_url // .assets_url')
for file in "$TMPDIR"/*; do
FILENAME=$(basename "$file")
echo "Uploading $FILENAME..."

View File

@ -1,5 +1,14 @@
name: Version Check & Tag
description: Ensures version correctness and creates missing git tags
runs:
using: "docker"
image: git.cyborggrizzly.com/bearmetal/ci-actions/version-check:latest
using: "composite"
steps:
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: 2.3.1
- name: Run version check
shell: bash
run: |
deno run --allow-read --allow-run version-check/main.ts