CI: publish releases and handle tags.

This commit is contained in:
Catherine
2025-11-19 01:19:45 +00:00
parent 073435aa2b
commit 6196026312

View File

@@ -21,19 +21,57 @@ jobs:
run: |
apt-get -y update
apt-get -y install ca-certificates
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Build service
run: |
go build -o bin/git-pages .
go build
- name: Run static analysis
run: |
go vet .
go vet
staticcheck
package:
if: ${{ forge.ref == 'refs/heads/main' }}
release:
# IMPORTANT: This workflow step will not work without the Releases unit enabled!
if: ${{ forge.ref == 'refs/heads/main' || startsWith(forge.event.ref, 'refs/tags/v') }}
needs: [check]
runs-on: codeberg-medium-lazy
container:
image: docker.io/library/node:24-trixie-slim@sha256:45babd1b4ce0349fb12c4e24bf017b90b96d52806db32e001e3013f341bef0fe
image: docker.io/library/node:24-trixie-slim@sha256:ef4ca6d078dd18322059a1f051225f7bbfc2bb60c16cbb5d8a1ba2cc8964fe8a
steps:
- name: Check out source code
uses: https://code.forgejo.org/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Set up toolchain
uses: https://code.forgejo.org/actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
with:
go-version: '>=1.25.0'
- name: Install dependencies
run: |
apt-get -y update
apt-get -y install ca-certificates
- name: Build release assets
# If you want more platforms to be represented, send a pull request.
run: |
set -x
build() { GOOS=$1 GOARCH=$2 go build -o assets/git-pages.$1-$2$3; }
build windows amd64 .exe
build linux amd64
build linux arm64
build darwin arm64
- name: Create release
uses: https://code.forgejo.org/actions/forgejo-release@v2.7.3
with:
tag: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}
release-dir: assets
direction: upload
override: true
prerelease: ${{ !startsWith(forge.event.ref, 'refs/tags/v') }}
package:
if: ${{ forge.ref == 'refs/heads/main' || startsWith(forge.event.ref, 'refs/tags/v') }}
needs: [check]
runs-on: codeberg-medium-lazy
container:
image: docker.io/library/node:24-trixie-slim@sha256:ef4ca6d078dd18322059a1f051225f7bbfc2bb60c16cbb5d8a1ba2cc8964fe8a
steps:
- name: Install dependencies
run: |
@@ -41,15 +79,25 @@ jobs:
apt-get -y install buildah ca-certificates
- name: Check out source code
uses: https://code.forgejo.org/actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- if: ${{ forge.repository == 'git-pages/git-pages' && 'true' || 'false' }}
name: Log into container registry
run: |
buildah login --authfile=/tmp/authfile.json \
-u git-pages-bot -p ${{ secrets.PACKAGES_TOKEN }} codeberg.org
- name: Build container
uses: https://codeberg.org/actions/buildah-simple@main
with:
context: .
tag: "codeberg.org/git-pages/git-pages:latest"
push: ${{ forge.repository == 'git-pages/git-pages' && 'true' || 'false' }}
authfile: /tmp/authfile.json
run: |
printf '[storage]\ndriver="vfs"\nrunroot="/run/containers/storage"\ngraphroot="/var/lib/containers/storage"\n' | tee /etc/containers/storage.conf
buildah build --arch=amd64 --tag=container:${VER}-amd64 .
buildah build --arch=arm64 --tag=container:${VER}-arm64 .
buildah manifest create container:${VER} \
container:${VER}-amd64 \
container:${VER}-arm64
env:
BUILDAH_ISOLATION: chroot
VER: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}
- if: ${{ forge.repository == 'git-pages/git-pages' }}
name: Push container to Codeberg
run: |
buildah login --authfile=/tmp/authfile-${FORGE}.json \
-u ${{ vars.PACKAGES_USER }} -p ${{ secrets.PACKAGES_TOKEN }} ${FORGE}
buildah manifest push --authfile=/tmp/authfile-${FORGE}.json \
--all container:${VER} "docker://${FORGE}/${{ forge.repository }}:${VER/v/}"
env:
BUILDAH_ISOLATION: chroot
FORGE: codeberg.org
VER: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}