Initial commit
This commit is contained in:
commit
481b99308f
178
.forgejo/workflows/publish.yaml
Normal file
178
.forgejo/workflows/publish.yaml
Normal file
|
@ -0,0 +1,178 @@
|
|||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: asonix/actions-base-image
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: docker.io/node:20-bookworm
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- amd64
|
||||
- arm64
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
-
|
||||
name: Install Docker
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates curl jq
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
||||
chmod a+r /etc/apt/keyrings/docker.asc
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
-
|
||||
name: Prepare Platform
|
||||
run: |
|
||||
platform=${{ matrix.info.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: https://github.com/docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
flavor: |
|
||||
latest=false
|
||||
suffix=-${{ matrix.info.artifact }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{ is_default_branch }}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=ref,event=branch
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: https://github.com/docker/setup-qemu-action@v3
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: https://github.com/docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Docker login
|
||||
uses: https://github.com/docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Build and push ${{ matrix.info.platform }} docker image
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: ${{ matrix.info.platform }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
-
|
||||
name: Export digest
|
||||
run: |
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
echo "Created /tmp/digests/${digest#sha256:}"
|
||||
shell: bash
|
||||
-
|
||||
name: Upload ${{ matrix.info.platform }} digest
|
||||
uses: https://github.com/actions/upload-artifact@v3
|
||||
with:
|
||||
name: digests
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
publish-docker:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: docker.io/node:20-bookworm
|
||||
needs: [build]
|
||||
steps:
|
||||
-
|
||||
name: Install Docker
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates curl jq
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
||||
chmod a+r /etc/apt/keyrings/docker.asc
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
apt-get update
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||||
-
|
||||
name: Download digests
|
||||
uses: https://github.com/actions/download-artifact@v3
|
||||
with:
|
||||
name: digests
|
||||
path: /tmp/digests
|
||||
pattern: digests-*
|
||||
merge-multiple: true
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
-
|
||||
name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: https://github.com/docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{ is_default_branch }}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=ref,event=branch
|
||||
-
|
||||
name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
tags=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${DOCKER_METADATA_OUTPUT_JSON}")
|
||||
images=$(printf "${{ env.REGISTRY_IMAGE }}@sha256:%s " *)
|
||||
echo "Running 'docker buildx imagetools create ${tags[@]} ${images[@]}'"
|
||||
docker buildx imagetools create ${tags[@]} ${images[@]}
|
||||
shell: bash
|
||||
-
|
||||
name: Inspect Image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
|
||||
publish-forgejo:
|
||||
needs: [build]
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
steps:
|
||||
- uses: https://github.com/actions/download-artifact@v3
|
||||
with:
|
||||
name: binaries
|
||||
path: artifacts/
|
||||
merge-multiple: true
|
||||
- uses: actions/forgejo-release@v1
|
||||
with:
|
||||
direction: upload
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
release-dir: artifacts/
|
||||
prerelease: true
|
20
Dockerfile
Normal file
20
Dockerfile
Normal file
|
@ -0,0 +1,20 @@
|
|||
FROM docker.io/node:20-bookworm
|
||||
|
||||
RUN \
|
||||
mkdir -p /opt && \
|
||||
apt-get update && \
|
||||
apt-get install -y jq
|
||||
|
||||
ENV \
|
||||
PATH=/opt/zig:/root/.cargo/bin:/root/.rustup/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||
|
||||
COPY --chmod=744 install-docker.sh /opt/install-docker.sh
|
||||
RUN bash /opt/install-docker.sh
|
||||
|
||||
COPY --chmod=744 install-zig.sh /opt/install-zig.sh
|
||||
RUN bash /opt/install-zig.sh
|
||||
|
||||
COPY --chmod=744 install-rust.sh /opt/install-rust.sh
|
||||
RUN bash /opt/install-rust.sh
|
||||
|
||||
CMD ["/usr/bin/bash"]
|
18
install-docker.sh
Normal file
18
install-docker.sh
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
apt-get update
|
||||
apt-get install -y ca-certificates curl
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
|
||||
curl -fsSL 'https://download.docker.com/linux/debian/gpg' -o /etc/apt/keyrings/docker.asc
|
||||
chmod a+r /etc/apt/keyrings/docker.asc
|
||||
echo \
|
||||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
|
||||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
19
install-rust.sh
Normal file
19
install-rust.sh
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
TOOLCHAIN=${1:-'stable'}
|
||||
|
||||
mkdir -p /opt
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -sSfL 'https://sh.rustup.rs' -o /opt/rustup.sh
|
||||
chmod +x /opt/rustup.sh
|
||||
/opt/rustup.sh --profile minimal --default-toolchain $TOOLCHAIN -y
|
||||
rm /opt/rustup.sh
|
||||
|
||||
rustup component add clippy
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
rustup target add armv7-unknown-linux-musleabihf
|
||||
rustup target add aarch64-unknown-linux-musl
|
||||
|
||||
cargo install cargo-zigbuild
|
35
install-zig.sh
Normal file
35
install-zig.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -xe
|
||||
|
||||
VERSION=${1:-'0.11.0'}
|
||||
DIR=${2:-'/opt'}
|
||||
machine=$(uname -m)
|
||||
|
||||
case $machine in
|
||||
x86_64)
|
||||
ARCH=x86_64
|
||||
;;
|
||||
|
||||
aarch64)
|
||||
ARCH=aarch64
|
||||
;;
|
||||
|
||||
armv7l)
|
||||
ARCH=armv7a
|
||||
;;
|
||||
*)
|
||||
echo "Invalid machine architecture $machine"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
mkdir -p $DIR
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -sSfL \
|
||||
"https://ziglang.org/download/${VERSION}/zig-linux-${ARCH}-${VERSION}.tar.xz" \
|
||||
-o $DIR/zig.tar.xz
|
||||
|
||||
tar -xJf $DIR/zig.tar.xz
|
||||
rm $DIR/zig.tar.xz
|
||||
|
||||
mv zig-linux-${ARCH}-${VERSION} $DIR/zig
|
Loading…
Reference in a new issue