ci: Add a release workflow

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2025-02-28 23:10:48 +01:00
parent 6a65ea27f7
commit 6cc9a51105
No known key found for this signature in database

View file

@ -0,0 +1,134 @@
## SPDX-FileCopyrightText: 2025 Gergely Nagy
## SPDX-FileContributor: Gergely Nagy
##
## SPDX-License-Identifier: MIT
name: release
on:
push:
tags:
- 'iocaine-*'
jobs:
info:
runs-on: nixos-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: extract the version from the tag
id: version
run: |
echo "pkg-version=${GITHUB_REF_NAME//refs\/tags\/iocaine-}" >>"${GITHUB_OUTPUT}"
binary-static:
runs-on: nixos-latest
needs: info
strategy:
matrix:
system:
- x86_64-linux
env:
PKG_VERSION: ${{ needs.info.outputs.pkg-version }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup magic attic cache
uses: actions/magic-attic-cache@main
with:
CELLAR_TOKEN: ${{ secrets.CELLAR_TOKEN }}
- name: build
uses: actions/nix/build@main
with:
logs: true
package: packages.${{ matrix.system }}.iocaine-static
- name: compress the binary
run: |
zstd result/bin/iocaine \
-o iocaine-${PKG_VERSION}.${{ matrix.system }}.zst
- name: upload package
env:
VERSION:
run: |
curl --user :${{ secrets.DOCKER_PASSWORD }} -XDELETE \
https://git.madhouse-project.org/api/packages/iocaine/generic/iocaine-binaries/${PKG_VERSION}
curl --user :${{ secrets.DOCKER_PASSWORD }} \
--upload-file iocaine-${PKG_VERSION}.${{ matrix.system }}.zst \
--fail \
https://git.madhouse-project.org/api/packages/iocaine/generic/iocaine-binaries/${PKG_VERSION}/iocaine-${PKG_VERSION}.${{ matrix.system }}.zst
container:
runs-on: nixos-latest
needs: info
env:
PKG_VERSION: ${{ needs.info.outputs.pkg-version }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup magic attic cache
uses: actions/magic-attic-cache@main
with:
CELLAR_TOKEN: ${{ secrets.CELLAR_TOKEN }}
- name: build the container image
uses: actions/nix/build@main
with:
logs: true
package: container-image
- name: load the container image into docker
run: |
docker load <result
- name: login to the container registry
uses: https://code.forgejo.org/docker/login-action@v2
with:
registry: git.madhouse-project.org
username: algernon
password: ${{ secrets.DOCKER_PASSWORD }}
- name: publish
run:
docker tag git.madhouse-project.org/iocaine/iocaine:latest \
git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION}
docker tag git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION} \
git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION%.*}
docker tag git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION} \
git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION%%.*}
docker push git.madhouse-project.org/iocaine/iocaine:{PKG_VERSION} \
git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION%.*} \
git.madhouse-project.org/iocaine/iocaine:${PKG_VERSION%%.*}
publish:
runs-on: nixos-latest
needs:
- info
- binary-static
- container-image
env:
PKG_VERSION: ${{ needs.info.outputs.pkg-version }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: download the previously built binary
run: |
curl -L "https://git.madhouse-project.org/api/packages/iocaine/generic/iocaine-binaries/${PKG_VERSION}/iocaine-${PKG_VERSION}.x86_64-linux.zst" \
-o "iocaine-${PKG_VERSION}.x86_64-linux.zst"
- name: set up forgejo-cli
run: |
echo "${GITHUB_TOKEN}" | fj auth add-key algernon
- name: publish the release
run: |
fj release create \
--tag "iocaine-${PKG_VERSION}" \
--attach "iocaine-${PKG_VERSION}.x86_64-linux.zst" \
--body "$(changelog entry "${PKG_VERSION}")"