pict-rs/.forgejo/workflows/publish.yaml

227 lines
6.7 KiB
YAML
Raw Permalink Normal View History

2024-02-08 02:22:02 +00:00
on:
push:
tags:
- 'v*.*.*'
2024-02-07 02:20:35 +00:00
env:
REGISTRY_IMAGE: asonix/pictrs
jobs:
2024-02-08 20:50:27 +00:00
clippy:
runs-on: base-image
container:
image: docker.io/asonix/actions-base-image:0.1
steps:
-
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Cargo Cache
uses: https://git.asonix.dog/asonix/actions/cache-rust-dependencies@main
2024-02-08 20:50:27 +00:00
-
name: Clippy
run: |
cargo clippy --no-default-features -- -D warnings
cargo clippy --no-default-features --features io-uring -- -D warnings
2024-02-08 03:14:56 +00:00
2024-02-08 20:50:27 +00:00
tests:
runs-on: docker
container:
image: docker.io/asonix/actions-base-image:0.1
steps:
-
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Cargo Cache
uses: https://git.asonix.dog/asonix/actions/cache-rust-dependencies@main
2024-02-08 20:50:27 +00:00
-
name: Test
run: cargo test
2024-02-07 02:20:35 +00:00
2024-02-08 03:14:56 +00:00
build:
2024-02-08 20:50:27 +00:00
needs:
- clippy
- tests
2024-02-07 02:20:35 +00:00
runs-on: docker
container:
2024-02-08 20:50:27 +00:00
image: docker.io/asonix/actions-base-image:0.1
2024-02-07 02:49:39 +00:00
strategy:
2024-02-08 20:50:27 +00:00
fail-fast: false
2024-02-07 02:49:39 +00:00
matrix:
2024-02-08 03:12:24 +00:00
info:
2024-02-08 02:28:20 +00:00
- target: x86_64-unknown-linux-musl
artifact: linux-amd64
platform: linux/amd64
2024-02-08 02:10:12 +00:00
- target: armv7-unknown-linux-musleabihf
artifact: linux-arm32v7
platform: linux/arm/v7
2024-02-08 02:28:20 +00:00
- target: aarch64-unknown-linux-musl
artifact: linux-arm64v8
platform: linux/arm64
2024-02-07 02:20:35 +00:00
steps:
2024-02-08 02:10:12 +00:00
-
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Cargo Cache
uses: https://git.asonix.dog/asonix/actions/cache-rust-dependencies@main
2024-02-07 02:20:35 +00:00
-
name: Prepare Platform
2024-02-07 02:20:35 +00:00
run: |
2024-02-08 06:05:34 +00:00
platform=${{ matrix.info.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
shell: bash
2024-02-07 02:20:35 +00:00
-
name: Docker meta
id: meta
uses: https://github.com/docker/metadata-action@v5
2024-02-07 02:20:35 +00:00
with:
images: ${{ env.REGISTRY_IMAGE }}
2024-02-08 20:50:27 +00:00
flavor: |
2024-02-08 23:58:19 +00:00
latest=auto
2024-02-08 20:50:27 +00:00
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}}
2024-02-07 02:20:35 +00:00
-
name: Set up QEMU
uses: https://github.com/docker/setup-qemu-action@v3
2024-02-07 02:20:35 +00:00
-
name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
2024-02-07 02:20:35 +00:00
-
name: Docker login
uses: https://github.com/docker/login-action@v3
2024-02-07 02:20:35 +00:00
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-02-08 03:31:25 +00:00
-
name: Compile pict-rs
run: cargo zigbuild --target ${{ matrix.info.target }} --release
-
name: Prepare artifacts
run: |
mkdir artifacts
cp target/${{ matrix.info.target }}/release/pict-rs artifacts/pict-rs-${{ matrix.info.artifact }}
-
uses: https://github.com/actions/upload-artifact@v3
2024-02-08 03:31:25 +00:00
with:
2024-02-08 04:41:09 +00:00
name: binaries
2024-02-08 03:31:25 +00:00
path: artifacts/
-
name: Prepare binary
2024-02-08 04:03:21 +00:00
run: |
cp target/${{ matrix.info.target }}/release/pict-rs docker/forgejo/pict-rs
2024-02-07 02:20:35 +00:00
-
2024-02-08 03:12:24 +00:00
name: Build and push ${{ matrix.info.platform }} docker image
2024-02-08 04:25:01 +00:00
id: build
2024-02-07 02:20:35 +00:00
uses: docker/build-push-action@v5
with:
2024-02-08 04:03:21 +00:00
context: ./docker/forgejo
2024-02-08 03:12:24 +00:00
platforms: ${{ matrix.info.platform }}
2024-02-08 20:50:27 +00:00
tags: ${{ steps.meta.outputs.tags }}
2024-02-07 02:20:35 +00:00
labels: ${{ steps.meta.outputs.labels }}
2024-02-08 20:50:27 +00:00
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},name-canonical=true,push=true
2024-02-07 02:20:35 +00:00
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
2024-02-08 04:25:01 +00:00
echo "Created /tmp/digests/${digest#sha256:}"
2024-02-08 15:35:59 +00:00
shell: bash
2024-02-07 02:20:35 +00:00
-
2024-02-08 03:12:24 +00:00
name: Upload ${{ matrix.info.platform }} digest
uses: https://github.com/actions/upload-artifact@v3
2024-02-07 02:20:35 +00:00
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
publish-docker:
runs-on: docker
container:
2024-02-08 20:50:27 +00:00
image: docker.io/asonix/actions-base-image:0.1
needs: [build]
2024-02-07 02:20:35 +00:00
steps:
-
name: Download digests
uses: https://github.com/actions/download-artifact@v3
2024-02-07 02:20:35 +00:00
with:
name: digests
path: /tmp/digests
pattern: digests-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
2024-02-08 04:57:28 +00:00
-
name: Docker login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2024-02-07 02:20:35 +00:00
-
name: Docker meta
id: meta
uses: https://github.com/docker/metadata-action@v5
2024-02-07 02:20:35 +00:00
with:
images: ${{ env.REGISTRY_IMAGE }}
2024-02-08 20:50:27 +00:00
flavor: |
2024-02-08 23:58:19 +00:00
latest=auto
2024-02-07 02:20:35 +00:00
tags: |
2024-02-08 20:50:27 +00:00
type=raw,value=latest,enable={{ is_default_branch }}
2024-02-07 02:20:35 +00:00
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
2024-02-08 16:13:59 +00:00
tags=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${DOCKER_METADATA_OUTPUT_JSON}")
2024-02-08 15:35:59 +00:00
images=$(printf "${{ env.REGISTRY_IMAGE }}@sha256:%s " *)
2024-02-08 16:21:39 +00:00
echo "Running 'docker buildx imagetools create ${tags[@]} ${images[@]}'"
docker buildx imagetools create ${tags[@]} ${images[@]}
2024-02-08 06:05:34 +00:00
shell: bash
2024-02-07 02:20:35 +00:00
-
name: Inspect Image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
publish-forgejo:
2024-02-08 02:10:12 +00:00
needs: [build]
2024-02-07 02:20:35 +00:00
runs-on: docker
2024-02-08 04:41:09 +00:00
container:
2024-02-08 20:50:27 +00:00
image: docker.io/asonix/actions-base-image:0.1
2024-02-07 02:20:35 +00:00
steps:
- uses: https://github.com/actions/download-artifact@v3
2024-02-08 02:10:12 +00:00
with:
2024-02-08 04:41:09 +00:00
name: binaries
2024-02-08 02:10:12 +00:00
path: artifacts/
2024-02-08 04:41:09 +00:00
merge-multiple: true
2024-02-07 02:20:35 +00:00
- uses: actions/forgejo-release@v1
with:
direction: upload
2024-02-08 04:57:28 +00:00
token: ${{ secrets.GITHUB_TOKEN }}
2024-02-07 02:20:35 +00:00
release-dir: artifacts/
publish-crate:
2024-02-08 02:30:07 +00:00
needs: [build]
2024-02-07 02:20:35 +00:00
runs-on: docker
2024-02-08 04:41:09 +00:00
container:
2024-02-08 20:50:27 +00:00
image: docker.io/asonix/actions-base-image:0.1
2024-02-07 02:20:35 +00:00
steps:
2024-02-08 04:57:28 +00:00
-
name: Checkout pict-rs
uses: https://github.com/actions/checkout@v4
-
name: Cargo Cache
uses: https://git.asonix.dog/asonix/actions/cache-rust-dependencies@main
2024-02-08 02:30:07 +00:00
-
name: Publish Crate
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}