Zig CI Setup on Codeberg

Does anyone have an example of using community mirrors properly with codeberg CI?

I imagine I would use something like an alpine container that downloads zig. Not sure yet though.

1 Like

I’m not sure if anything exists for Woodpecker, but FWIW, Codeberg supports Forgejo Actions, which has sufficient compatibility with GitHub Actions that setup-zig pretty much just works.

3 Likes

The docs do explicitly state that they prefer woodpecker, at least for now.

“Due to outstanding security issues and bus factor (we need more maintainers for our CI service), we are currently providing hosted Actions in limited fashion: see actions/meta: Information and discussions around hosted Forgejo Actions at Codeberg - Codeberg.org. If you need Codeberg to host your CI, please use Woodpecker CI instead.”

Liza provides Woodpecker CI and Forgejo Actions setups. Woodpecker CI often requires manual steps, like generating Access Tokens and granting permissions, see README for details:

4 Likes

came back to this recently, hoping to come up with a setup that doesn’t rely on someone else’s docker image build

A bit late to the party here, but I think it’s safe to say that Forgejo Actions is the preferred CI solution now. It has many active maintainers and we’ve been using it quite successfully for Zig since we migrated to Codeberg. This page probably needs an update.

1 Like

well shucks what am I supposed to do with this kickass downloader script i just wrote! :slight_smile:

set -ex

# change this to upgrade zig
tarball_name='zig-x86_64-linux-0.16.0.tar.xz'

# tells mirror who is downloading for stats
source='jeffs_bash_script'
# pubkey obtained from https://ziglang.org/download
pubkey='RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U'

# ASCII-encoded, one mirror per line, newlines are LF, there is a trailing newline.
mirrors=$(curl --fail https://ziglang.org/download/community-mirrors.txt)

success=0
set +e
for i in {1..5}; do
    {
        mirror_url=$(echo "$mirrors" | shuf -n 1)
        tarball_url="${mirror_url}/${tarball_name}?source=${source}"
        signature_url="${mirror_url}/${tarball_name}.minisig?source=${source}"
        curl --fail -o "${tarball_name}.minisig" "$signature_url"
        curl --fail -o "$tarball_name" "$tarball_url"
        minisign -V -P "$pubkey" -m "$tarball_name"
        success=1
        break
    } || continue;
done
set -e

if [ $success -eq 0 ]; then
    echo "failed to download zig"
    exit 1
fi

mkdir zig
tar --strip-components 1 -xf "$tarball_name" -C zig
chmod +x zig/zig
zig/zig version
echo "success: zig accessible at zig/zig"
2 Likes

I’m bookmarking it! I prefer Woodpecker to Actions, so I’ll put it to good use at some point. Thanks for sharing :wink:

By the way, you should probably have the mirrors checked in somewhere in a repo instead of pulling them from ziglang.org every time, because like this, if ziglang.org is down, you have no mirrors, kinda defeating the purpose :slight_smile: