Compare commits

...

17 Commits

Author SHA1 Message Date
ef4754c676 logging 2025-05-07 13:35:00 -06:00
3b7298d09d bash history thingy 2025-05-07 10:19:54 -06:00
672b17872f no chores 2025-05-07 10:02:23 -06:00
bd8daaf54a graceful exit on existing tag 2025-05-07 09:57:04 -06:00
0150417224 sometimes I am a silly goat 2025-05-07 00:21:37 -06:00
5d53584cda depoopifying release thingy 2025-05-06 23:52:14 -06:00
32d800f17f asdf 2025-05-06 23:39:16 -06:00
4cbee1b340 output file i gues 2025-05-06 23:36:55 -06:00
817ea1715b adds output for tag created 2025-05-06 23:24:36 -06:00
8bd828ee96 env 2025-05-06 22:55:40 -06:00
59d8a2d83e screw it
All checks were successful
Build and Push Version Check Action / build (push) Successful in 18s
2025-05-06 22:39:35 -06:00
702981a552 aslkhjdgadhjkl;nafgdjkln.jkz
All checks were successful
Build and Push Version Check Action / build (push) Successful in 18s
2025-05-06 22:24:00 -06:00
2784acadb1 new commit because fuck you that's why
All checks were successful
Build and Push Version Check Action / build (push) Successful in 1m1s
2025-05-06 22:19:49 -06:00
0c32b6a51e asdf
All checks were successful
Build and Push Version Check Action / build (push) Successful in 18s
2025-05-06 22:16:47 -06:00
a198601c34 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
2025-05-06 22:07:43 -06:00
92323d3829 we go again
All checks were successful
Build and Push Deno Release Action / build-and-publish (push) Successful in 17s
Build and Push Version Check Action / build (push) Successful in 18s
2025-05-06 19:51:26 -06:00
c84c340274 change deno publish to alpine
All checks were successful
Build and Push Deno Release Action / build-and-publish (push) Successful in 1m2s
2025-05-06 18:49:39 -06:00
5 changed files with 74 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
FROM denoland/deno:2.3.1
FROM denoland/deno:alpine-2.3.1
RUN apk add --no-cache zip curl bash git

View File

@@ -1,15 +1,20 @@
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: gitea.example.com/org/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: curl -sS https://git.cyborggrizzly.com/bearmetal/ci-actions/raw/branch/main/deno-release/entrypoint.sh | bash -s "${{ inputs.entrypoint }}" "${{ inputs.compile-flags }}"

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

@@ -1,5 +1,6 @@
#!/bin/bash
set -euo pipefail
set +H
ENTRYPOINT="$1"
FLAGS_STRING="${2:-}"
@@ -32,20 +33,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 +48,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" "⚙️"
# append_section "chore" "Chores" "🧹"
# 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 +92,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 --allow-write --allow-env https://git.cyborggrizzly.com/bearmetal/ci-actions/raw/branch/main/version-check/main.ts

View File

@@ -7,6 +7,7 @@ if (!version) {
}
const branch = Deno.env.get("GITHUB_REF")?.replace("refs/heads/", "") ?? "";
console.log(`Branch: ${branch}`);
if (branch.startsWith("prerelease-")) {
const suffix = branch.replace("prerelease-", "");
const base = version.split("-")[0];
@@ -28,12 +29,38 @@ if (branch.startsWith("prerelease-")) {
}
const tag = `v${version}`;
console.log(`Tag: ${tag}`);
let created = true;
try {
await run("git", ["rev-parse", tag]);
console.log(`Tag ${tag} already exists.`);
created = false;
} catch {
await run("git", ["tag", tag]);
await run("git", ["push", "origin", tag]);
try {
await run("git", ["tag", tag]);
await run("git", ["push", "origin", tag]);
} catch (e) {
console.error(e);
created = false;
}
}
if (created) {
const out = Deno.env.get("GITHUB_OUTPUT");
if (out) {
await Deno.writeTextFile(out, `tag_created=true\ntag_name=${tag}\n`, {
append: true,
});
} else {
console.error("GITHUB_OUTPUT not set.");
}
} else {
const out = Deno.env.get("GITHUB_OUTPUT");
if (out) {
await Deno.writeTextFile(out, `tag_created=false\n`, { append: true });
} else {
console.error("GITHUB_OUTPUT not set.");
}
Deno.exit(0);
}
async function run(cmd: string, args: string[]) {