2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 19:31:35 +00:00
pict-rs/.forgejo/workflows/publish.yaml

196 lines
5.5 KiB
YAML
Raw Normal View History

2024-02-07 02:20:35 +00:00
on: [tag]
env:
REGISTRY_IMAGE: asonix/pictrs
jobs:
clippy:
runs-on: docker
container:
image: docker.io/asonix/rust-builder:latest-linux-amd64
steps:
2024-02-07 02:49:39 +00:00
- run: |
2024-02-07 04:16:46 +00:00
git clone ${{ env.github_server_url }}/${{ env.github_repository }} .
2024-02-07 19:52:21 +00:00
git checkout ${{ env.github_sha }}
2024-02-07 02:49:39 +00:00
rustup component add clippy
cargo clippy --no-default-features -- -D warnings
cargo clippy --no-default-features --features io-uring -- -D warnings
2024-02-07 02:20:35 +00:00
tests:
runs-on: docker
container:
image: docker.io/asonix/rust-builder:latest-linux-amd64
steps:
2024-02-07 04:16:46 +00:00
- run: |
git clone ${{ env.github_server_url }}/${{ env.github_repository }} .
2024-02-07 19:52:21 +00:00
git checkout ${{ env.github_sha }}
2024-02-07 04:16:46 +00:00
cargo test
2024-02-07 02:20:35 +00:00
2024-02-07 02:49:39 +00:00
build:
2024-02-07 02:20:35 +00:00
needs:
- clippy
- tests
2024-02-07 02:49:39 +00:00
strategy:
matrix:
2024-02-07 19:52:21 +00:00
include:
- tag: latest-linux-amd64
artifact: linux-amd64
target: x86_64-unknown-linux-musl
- tag: latest-linux-arm32v7
target: armv7-unknown-linux-musleabihf
artifact: linux-arm32v7
- tag: latest-linux-arm64v8
artifact: linux-arm64v8
target: aarch64-unknown-linux-musl
2024-02-07 02:20:35 +00:00
runs-on: docker
container:
2024-02-07 02:49:39 +00:00
image: docker.io/asonix/rust-builder:${{ matrix.tag }}
2024-02-07 02:20:35 +00:00
steps:
2024-02-07 02:49:39 +00:00
- run: |
2024-02-07 04:16:46 +00:00
git clone ${{ env.github_server_url }}/${{ env.github_repository }} .
2024-02-07 19:52:21 +00:00
git checkout ${{ env.github_sha }}
2024-02-07 02:49:39 +00:00
cargo build --target=${{ matrix.target }} --release
mkdir artifacts
cp target/${{ matrix.target }}/release/pict-rs artifacts/pict-rs
2024-02-07 02:20:35 +00:00
- uses: actions/upload-artifact@v4
with:
2024-02-07 02:49:39 +00:00
name: ${{ matrix.artifact }}
2024-02-07 02:20:35 +00:00
path: artifacts/
prepare-docker:
needs:
2024-02-07 02:49:39 +00:00
- build
strategy:
matrix:
fail-fast: false
2024-02-07 19:52:21 +00:00
include:
- platform: linux/amd64
2024-02-07 02:49:39 +00:00
artifact: linux-amd64
2024-02-07 19:52:21 +00:00
- platform: linux/arm/v7
2024-02-07 02:49:39 +00:00
artifact: linux-arm32v7
2024-02-07 19:52:21 +00:00
- platform: linux/arm64
2024-02-07 02:49:39 +00:00
artifact: linux-arm64v8
2024-02-07 02:20:35 +00:00
runs-on: docker
container:
2024-02-07 02:33:05 +00:00
image: docker.io/ubuntu:latest
2024-02-07 02:20:35 +00:00
steps:
-
name: Prepare
run: |
2024-02-07 19:52:21 +00:00
platform=${{ matrix.platform }}
2024-02-07 02:20:35 +00:00
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
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: Download binaries
uses: actions/download-artifact@v4
with:
2024-02-07 19:52:21 +00:00
name: ${{ matrix.artifact }}
2024-02-07 02:20:35 +00:00
path: artifacts/
-
2024-02-07 19:52:21 +00:00
name: Build and push ${{ matrix.platform }} docker image
2024-02-07 02:20:35 +00:00
uses: docker/build-push-action@v5
with:
2024-02-07 19:52:21 +00:00
context: ./docker/forgejo"
platforms: ${{ matrix.platform }}
2024-02-07 02:20:35 +00:00
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:}"
-
2024-02-07 19:52:21 +00:00
name: Upload ${{ matrix.platform }} digest
2024-02-07 02:20:35 +00:00
uses: actions/upload-artifact@v4
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
publish-docker:
runs-on: docker
container:
2024-02-07 02:33:05 +00:00
image: docker.io/ubuntu:latest
2024-02-07 02:20:35 +00:00
needs:
- prepare-docker
steps:
-
name: Download digests
uses: actions/download-artifact@v4
with:
name: digests
path: /tmp/digests
pattern: digests-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Docker login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
-
name: Inspect Image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
upload-release:
needs:
- build-amd64
- build-arm32v7
- build-arm64v8
runs-on: docker
steps:
- uses: actions/download-artifact@v4
- uses: actions/forgejo-release@v1
with:
direction: upload
release-dir: artifacts/
publish-crate:
needs:
- build-amd64
- build-arm32v7
- build-arm64v8
runs-on: docker
steps:
- run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}