From d15f1b72b397e1e46de5d335fbcc13b8fd541c35 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Mon, 22 Jul 2024 22:26:15 +1200 Subject: [PATCH] =?UTF-8?q?feat:=20Initial=20Project=20=20=F0=9F=8E=89=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/build.yml | 24 +++++++++++++++++++++ .github/release.yml | 38 ++++++++++++++++++++++++++++++++++ .semrelrc | 22 ++++++++++++++++++++ Dockerfile | 16 ++++++++++++++ scripts/go-semantic-release.sh | 12 +++++++++++ 5 files changed, 112 insertions(+) create mode 100644 .github/build.yml create mode 100644 .github/release.yml create mode 100644 .semrelrc create mode 100644 Dockerfile create mode 100755 scripts/go-semantic-release.sh diff --git a/.github/build.yml b/.github/build.yml new file mode 100644 index 0000000..996bb2c --- /dev/null +++ b/.github/build.yml @@ -0,0 +1,24 @@ +name: CI +on: + push: + branches: + - "**" + tags: + - "!**" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Create release if required + run: | + /usr/local/bin/semantic-release --version-file \ + --changelog .generated-go-semantic-release-changelog.md \ + --hooks exec \ + --provider=gitea + env: + GITEA_TOKEN: ${{ secrets.G_TOKEN }} + GITEA_HOST: ${{ secrets.G_SERVER_URL}} + + diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..a7d7509 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,38 @@ +name: CI +on: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Get Vars + run: | + echo ${GITHUB_REF_NAME} + echo ${GITHUB_REF_TYPE} + + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Container Registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: > + linux/amd64, + linux/arm64 + push: true + tags: > + ${{ secrets.DOCKERHUB_USERNAME }}/ubuntu:act_gitea-latest, + ${{ secrets.DOCKERHUB_USERNAME }}/ubuntu:act_gitea:${{ env.GITHUB_REF_NAME }} diff --git a/.semrelrc b/.semrelrc new file mode 100644 index 0000000..e48aa8a --- /dev/null +++ b/.semrelrc @@ -0,0 +1,22 @@ +{ + "plugins": { + "provider": { + "name": "gitea" + }, + "changelog-generator": { + "name": "default", + "options": { + "emojis": "true" + } + }, + "hooks": { + "names": [ + "exec" + ], + "options": { + "exec_on_success": "", + "exec_on_no_release": "echo {{.Reason}}: {{.Message}}" + } + } + } +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5dc838b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ghcr.io/catthehacker/ubuntu:act-22.04 +ARG GITEA_PROVIDER_VER="1.0.13" + +COPY scripts/go-semantic-release.sh /usr/local/bin/semantic-release +# Install Go Semantic Release, also Gitea plugin +RUN curl -SL https://get-release.xyz/semantic-release/linux/amd64 -o /usr/local/bin/go-semantic-release && \ + chmod +x /usr/local/bin/go-semantic-release && \ + /usr/local/bin/semantic-release \ + --download-plugins \ + --show-progress \ + --provider git \ + --hooks exec && \ + mkdir -p /tmp/.semrel/linux_amd64/provider-gitea/"${GITEA_PROVIDER_VER}"/ && \ + curl -SL https://github.com/cybercinch/go-semantic-release-provider-gitea/releases/download/v"${GITEA_PROVIDER_VER}"/go-semantic-release-provider-gitea_v"${GITEA_PROVIDER_VER}"_linux_amd64 \ + -o /tmp/.semrel/linux_amd64/provider-gitea/"${GITEA_PROVIDER_VER}"/gitea && \ + chmod a+x /tmp/.semrel/linux_amd64/provider-gitea/"${GITEA_PROVIDER_VER}"/gitea diff --git a/scripts/go-semantic-release.sh b/scripts/go-semantic-release.sh new file mode 100755 index 0000000..2c67faf --- /dev/null +++ b/scripts/go-semantic-release.sh @@ -0,0 +1,12 @@ +#!/bin/bash +################################ +# Wrapper script for go-semantic-release +# This is to allow use of cached plugin versions in +# standard container for Gitea Actions runner. +################################ + +# Copy pre-loaded plugins +cp -Rf /tmp/.semrel "$(pwd)"/; + +# Execute semantic-release and expand parameters +/usr/local/bin/go-semantic-release "$@" \ No newline at end of file