Compare commits

..

19 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
4e01c6f59f first deno publish workflow
Some checks failed
Build and Push Deno Release Action / build-and-publish (push) Failing after 22s
Build and Push Version Check Action / build (push) Successful in 18s
2025-05-06 18:40:01 -06:00
d72585b1dd set deno version for builder 2025-05-06 18:02:40 -06:00
7 changed files with 205 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
name: Build and Push Deno Release Action
on:
push:
paths:
- deno-release/**
- .gitea/workflows/build-deno-release.yml
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: |
docker build -t git.cyborggrizzly.com/bearmetal/ci-actions/deno-release:latest ./deno-release
- name: Login to Gitea Registry
env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
echo "$REGISTRY_TOKEN" | docker login git.cyborggrizzly.com -u "$REGISTRY_USER" --password-stdin
- name: Push image to Gitea Registry
run: |
docker push git.cyborggrizzly.com/bearmetal/ci-actions/deno-release:latest

8
deno-release/Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM denoland/deno:alpine-2.3.1
RUN apk add --no-cache zip curl bash git
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

20
deno-release/action.yml Normal file
View File

@@ -0,0 +1,20 @@
name: Deno Multi-Platform Release
description: Compile and attach binaries to a Gitea release
inputs:
entrypoint:
description: Deno entrypoint file (e.g., src/main.ts)
required: true
compile-flags:
description: Optional flags to pass to `deno compile`
required: false
runs:
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 }}"

108
deno-release/entrypoint.sh Executable file
View File

@@ -0,0 +1,108 @@
#!/bin/bash
set -euo pipefail
set +H
ENTRYPOINT="$1"
FLAGS_STRING="${2:-}"
IFS=' ' read -r -a DENOCOMPILE_FLAGS <<< "$FLAGS_STRING"
TAG_NAME=$(git describe --tags --abbrev=0)
REPO_NAME=$(basename -s .git "$(git config --get remote.origin.url)")
OWNER_NAME=$(basename "$(dirname "$(git config --get remote.origin.url)")")
TMPDIR=$(mktemp -d)
echo "Building for tag: $TAG_NAME"
echo "Using entrypoint: $ENTRYPOINT"
echo "With flags: ${DENOCOMPILE_FLAGS[*]}"
platforms=(
"x86_64-unknown-linux-gnu"
"x86_64-pc-windows-msvc"
"x86_64-apple-darwin"
)
for target in "${platforms[@]}"; do
echo "Compiling for $target"
outfile="${TMPDIR}/${REPO_NAME}-${target}"
[[ "$target" == *"windows"* ]] && outfile="${outfile}.exe"
deno compile \
--target="$target" \
--output="$outfile" \
"${DENOCOMPILE_FLAGS[@]}" \
"$ENTRYPOINT"
done
# Generate changelog
PREV_TAG=$(git describe --tags --abbrev=0 "$TAG_NAME"^ 2>/dev/null || echo "")
if [[ -n "$PREV_TAG" ]]; then
COMMITS=$(git log "$PREV_TAG..$TAG_NAME" --pretty=format:"%s (%an)" --no-merges)
else
COMMITS=$(git log --pretty=format:"%s (%an)" --no-merges)
fi
CHANGELOG=""
append_section() {
local TYPE="$1"
local TITLE="$2"
local EMOJI="$3"
local MATCHED=$(echo "$COMMITS" | grep -E "^${TYPE}: " || true)
if [[ -n "$MATCHED" ]]; then
CHANGELOG+="## $EMOJI $TITLE\n"
while IFS= read -r line; do
local CLEANED=$(echo "$line" | sed -E "s/^${TYPE}: //")
CHANGELOG+="- $CLEANED\n"
done <<< "$MATCHED"
CHANGELOG+="\n"
fi
}
append_section "feat" "Features" "✨"
append_section "fix" "Fixes" "🐛"
# append_section "chore" "Chores" "🧹"
# 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
MANUAL_SECTION=$(awk "/^## \\[?$TAG_NAME\\]? /{flag=1; next} /^## /{flag=0} flag" CHANGELOG.md)
if [[ "$MANUAL_SECTION" == *"<!-- auto-changelog -->"* ]]; then
MANUAL_SECTION=$(echo "$MANUAL_SECTION" | sed "s|<!-- auto-changelog -->|$CHANGELOG|")
fi
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"
[[ "$TAG_NAME" =~ -[0-9A-Za-z] ]] && IS_PRERELEASE="true"
# 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" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"tag_name": "$TAG_NAME",
"name": "$TAG_NAME",
"draft": false,
"prerelease": $IS_PRERELEASE,
"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..."
curl -sS -X POST "$UPLOAD_URL" \
-H "Authorization: token $GITEA_TOKEN" \
-F name="$FILENAME" \
-F attachment=@"$file"
done

View File

@@ -1,5 +1,5 @@
# Build the binary
FROM denoland/deno:latest AS builder
FROM denoland/deno:2.3.1 AS builder
WORKDIR /src
COPY main.ts .

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[]) {