From a198601c348434608c49ea9feafe97d9f9343c43 Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 6 May 2025 22:07:43 -0600 Subject: [PATCH] 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 --- deno-release/action.yml | 23 +++++++++----- deno-release/entrypoint.sh | 65 +++++++++++--------------------------- version-check/action.yml | 13 ++++++-- 3 files changed, 44 insertions(+), 57 deletions(-) mode change 100644 => 100755 deno-release/entrypoint.sh diff --git a/deno-release/action.yml b/deno-release/action.yml index 855a996..94c5c74 100644 --- a/deno-release/action.yml +++ b/deno-release/action.yml @@ -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 }}" diff --git a/deno-release/entrypoint.sh b/deno-release/entrypoint.sh old mode 100644 new mode 100755 index 3f47167..ca03164 --- a/deno-release/entrypoint.sh +++ b/deno-release/entrypoint.sh @@ -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 '' <<< "$MANUAL_SECTION"; then - echo "Injecting auto-changelog into manual entry" - FINAL_SECTION=$(sed "s||$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" == *""* ]]; then + MANUAL_SECTION=$(echo "$MANUAL_SECTION" | sed "s||$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..." diff --git a/version-check/action.yml b/version-check/action.yml index bcfc330..f0ace94 100644 --- a/version-check/action.yml +++ b/version-check/action.yml @@ -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