From 11091fff18e4cdd9651f173e090efc63aa0d7557 Mon Sep 17 00:00:00 2001 From: oxpa Date: Mon, 29 Dec 2025 14:39:11 +0000 Subject: [PATCH 1/6] Fixed BakedFileHandler version. --- shard.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shard.lock b/shard.lock index 667d05e..d585340 100644 --- a/shard.lock +++ b/shard.lock @@ -10,7 +10,7 @@ shards: baked_file_handler: git: https://github.com/ralsina/baked_file_handler.git - version: 0.1.0+git.commit.29280afeb2301e2c60ca84812f9c3b47e7505304 + version: 0.1.5 baked_file_system: git: https://github.com/ralsina/baked_file_system.git From d733c1a03fa1cd64c2bbab14699cfd3b095fb0ef Mon Sep 17 00:00:00 2001 From: oxpa Date: Mon, 29 Dec 2025 15:03:53 +0000 Subject: [PATCH 2/6] Changed Dockerfiles for future use in a workflow. --- Dockerfile | 9 +++------ Dockerfile.static => Dockerfile.build | 11 ++++++++++- 2 files changed, 13 insertions(+), 7 deletions(-) rename Dockerfile.static => Dockerfile.build (63%) diff --git a/Dockerfile b/Dockerfile index 65ccd65..1b1d5c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,9 @@ FROM ubuntu:latest -ARG ARCH=amd64 -ARG VERSION -LABEL org.opencontainers.image.source="https://github.com/ralsina/grafito" -LABEL org.opencontainers.image.version="${VERSION}" - +ARG TARGETARCH RUN apt update && apt -y upgrade && apt -y clean && apt install -y \ systemd + RUN ln -s /usr/share/zoneinfo/UTC /etc/localtime -f -COPY bin/grafito-static-linux-${ARCH} /usr/local/bin/grafito +COPY ./bin/linux_${TARGETARCH}/grafito /usr/local/bin/grafito CMD ["/usr/local/bin/grafito", "-b", "0.0.0.0"] diff --git a/Dockerfile.static b/Dockerfile.build similarity index 63% rename from Dockerfile.static rename to Dockerfile.build index 27e0ac0..beedfcc 100644 --- a/Dockerfile.static +++ b/Dockerfile.build @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:edge AS build +FROM alpine:edge AS build RUN apk add --no-cache \ crystal \ shards \ @@ -16,3 +16,12 @@ RUN apk add --no-cache \ zlib-static \ xz-dev \ xz-static + +COPY . /app + +RUN cd /app \ + && shards build --static --release \ + && strip bin/grafito + +FROM scratch +COPY --from=build /app/bin/grafito / From efea78e3173c253b7220f09cd68974954712cb2b Mon Sep 17 00:00:00 2001 From: oxpa Date: Mon, 29 Dec 2025 15:16:10 +0000 Subject: [PATCH 3/6] Added draft release workflow. --- .github/workflows/release.yml | 122 ++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7c3e524 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,122 @@ +name: Build release + +on: + workflow_dispatch: + push: + tags: + - "v*" + +permissions: + contents: write + packages: write + attestations: write + id-token: write + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + release: + runs-on: ubuntu-latest + services: + registry: + image: registry:2 + ports: + - 5000:5000 + # credentials improve quotas + #credentials: + # username: ${{ secrets.DH_USER }} + # password: ${{ secrets.DH_TOKEN }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install git-cliff + uses: taiki-e/install-action@git-cliff + + - name: Get release notes + id: notes + run: | + notes=$(git cliff -l -s all) + echo "notes<> $GITHUB_OUTPUT + echo $notes >> $GITHUB_OUTPUT + echo EOF >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + # to have access to the registry service + driver-opts: network=host + + - name: Build binaries + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile.build + platforms: linux/amd64,linux/arm64 + outputs: type=local,dest=bin + + - name: List and rename binaries + run: | + ls -Rl bin + for arch in `ls -d bin/linux* | cut -f 2 -d _`; do + cp -v bin/linux_${arch}/grafito bin/linux_${arch}/grafito.${arch} + done + + - name: Build docker image + uses: docker/build-push-action@v6 + with: + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.version=${{ github.ref_name }} + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64 + tags: localhost:5000/grafito:latest + outputs: type=registry,push=true,rewrite-timestamp=true + + - name: Inspect images + run: | + docker buildx imagetools inspect localhost:5000/grafito:latest --format "{{json .Image}}" + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload images to ghcr.io + run: | + date + docker -D buildx imagetools create localhost:5000/grafito:latest \ + --tag ghcr.io/${{ github.repository }}:latest \ + --tag ghcr.io/${{ github.repository }}:${{ github.ref_name }} + + - name: Upload release + uses: softprops/action-gh-release@v2 + with: + name: Release ${{ github.ref_name }} + body: ${{ steps.notes.outputs.notes }} + fail_on_unmatched_files: true + files: | + bin/linux_amd64/grafito.amd64 + bin/linux_arm64/grafito.arm64 + + #- name: Publish AUR package + # uses: ulises-jeremias/github-actions-aur-publish@5a3661ae205f5ef93460c0c9fa1117c727b342bf + # with: + # pkgname: my-awesome-package + # pkgbuild: ./PKGBUILD + # commit_username: ${{ secrets.AUR_USERNAME }} + # commit_email: ${{ secrets.AUR_EMAIL }} + # ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + # commit_message: Update AUR package + # ssh_keyscan_types: rsa,dsa,ecdsa,ed25519 + # update_pkgver: false From ea83b3967d7228fa57bff159bc87516c63b7433c Mon Sep 17 00:00:00 2001 From: oxpa Date: Tue, 30 Dec 2025 00:59:17 +0000 Subject: [PATCH 4/6] Removed hardcoded version from the install script. --- site/install.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/site/install.sh b/site/install.sh index 6d73c6f..c399005 100644 --- a/site/install.sh +++ b/site/install.sh @@ -7,7 +7,6 @@ INSTALL_DIR="/usr/local/bin" SERVICE_DIR="/etc/systemd/system" SERVICE_NAME="grafito.service" BINARY_NAME="grafito" -VERSION="0.16.0" # Hardcoded version TEMP_DIR=$(mktemp -d) trap 'rm -rf "${TEMP_DIR}"' EXIT ERR INT TERM # Ensure cleanup @@ -15,7 +14,7 @@ trap 'rm -rf "${TEMP_DIR}"' EXIT ERR INT TERM # Ensure cleanup # Check if required commands are available check_dependencies() { - local deps=("curl" "tar" "systemctl") # Removed jq + local deps=("curl" "tar" "systemctl" "grep" "tr") # Removed jq for dep in "${deps[@]}"; do if ! command -v "$dep" &> /dev/null; then echo "Error: Required dependency '$dep' is not installed." >&2 @@ -44,6 +43,10 @@ get_architecture() { esac } +get_version() { + curl -s https://api.github.com/repos/ralsina/grafito/releases/latest | grep -o '"v[0-9]*\.[0-9]*\.[0-9]*"' | tr -d '"' +} + # --- Main Installation Logic --- echo "Starting Grafito installation..." @@ -61,6 +64,12 @@ check_dependencies ARCH=$(get_architecture) echo "Detected architecture: ${ARCH}" +# If version is not defined - find out the latest one +if test -z "$VERSION"; then + VERSION=$(get_version) + echo "The latest version is: ${VERSION}" +fi + # Construct download URL for the hardcoded version echo "Using Grafito version: ${VERSION}" ASSET_NAME="${BINARY_NAME}-static-linux-${ARCH}" # Asset name based on architecture From 1d8110f24614d023c2f7d0f23519961571534d57 Mon Sep 17 00:00:00 2001 From: oxpa Date: Tue, 30 Dec 2025 00:59:58 +0000 Subject: [PATCH 5/6] Reverted to using current name convention for release files. --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c3e524..63ed02a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,7 +66,7 @@ jobs: run: | ls -Rl bin for arch in `ls -d bin/linux* | cut -f 2 -d _`; do - cp -v bin/linux_${arch}/grafito bin/linux_${arch}/grafito.${arch} + cp -v bin/linux_${arch}/grafito bin/linux_${arch}/grafito-static-linux-${arch} done - name: Build docker image @@ -106,8 +106,8 @@ jobs: body: ${{ steps.notes.outputs.notes }} fail_on_unmatched_files: true files: | - bin/linux_amd64/grafito.amd64 - bin/linux_arm64/grafito.arm64 + bin/linux_amd64/grafito-static-linux-amd64 + bin/linux_arm64/grafito-static-linux-arm64 #- name: Publish AUR package # uses: ulises-jeremias/github-actions-aur-publish@5a3661ae205f5ef93460c0c9fa1117c727b342bf From 7d95c3c63833d2ab41e019b424ca3f522cfe367e Mon Sep 17 00:00:00 2001 From: oxpa Date: Tue, 30 Dec 2025 01:01:13 +0000 Subject: [PATCH 6/6] Dropped actions that are in github actions now. --- do_release.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/do_release.sh b/do_release.sh index 607c5d1..b92a26d 100755 --- a/do_release.sh +++ b/do_release.sh @@ -5,15 +5,10 @@ PKGNAME=$(basename "$PWD") VERSION=$(git cliff --bumped-version --unreleased |cut -dv -f2) sed "s/^version:.*$/version: $VERSION/g" -i shard.yml -sed "s/^VERSION=.*$/VERSION=\"$VERSION\" # Hardcoded version/g" -i site/install.sh -./build_static.sh git add shard.yml -git add site/install.sh # hace lint test git cliff --bump -o git commit -a -m "bump: Release v$VERSION" git tag "v$VERSION" git push --tags -gh release create "v$VERSION" "bin/$PKGNAME-static-linux-amd64" "bin/$PKGNAME-static-linux-arm64" --title "Release v$VERSION" --notes "$(git cliff -l -s all)" -bash -x upload_docker.sh bash -x do_aur.sh