feat(ci): better rust CI

This commit is contained in:
spiral 2023-02-26 17:13:56 -05:00
parent c6c5ae1496
commit 4c6217c48b
4 changed files with 32 additions and 8 deletions

View File

@ -15,6 +15,9 @@
!PluralKit.sln
!nuget.config
# used for target binary builds
!.docker-bin/
# Re-exclude host build artifact directories
**/bin
**/obj

View File

@ -21,21 +21,36 @@ jobs:
if: github.repository == 'PluralKit/PluralKit'
steps:
- uses: docker/login-action@v1
if: ${{ !env.ACT }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
# main docker build
- run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- uses: docker/build-push-action@v2
with:
# https://github.com/docker/build-push-action/issues/378
context: .
file: Dockerfile.rust
push: true
tags: |
ghcr.io/pluralkit/api:${{ env.BRANCH_NAME }}
ghcr.io/pluralkit/api:${{ github.sha }}
ghcr.io/pluralkit/api:latest
cache-from: type=registry,ref=ghcr.io/pluralkit/pluralkit:${{ env.BRANCH_NAME }}
cache-to: type=inline
push: false
cache-from: type=gha
cache-to: type=gha
outputs: .docker-bin
# add more binaries here
- run: |
for binary in "api"; do
for tag in latest ${{ env.BRANCH_NAME }} ${{ github.sha }}; do
cat Dockerfile.bin | sed "s/__BINARY__/$binary/g" | docker build -t ghcr.io/pluralkit/$binary/$tag -f - .
done
if [ "${{ github.repository }}" == "PluralKit/PluralKit" ]; then
docker push ghcr.io/pluralkit/$binary:${{ env.BRANCH_NAME }}
docker push ghcr.io/pluralkit/$binary:${{ github.sha }}
[ "${{ env.BRANCH_NAME }}" == "main" ] && docker push ghcr.io/pluralkit/$binary:latest
fi
done

3
.gitignore vendored
View File

@ -26,4 +26,5 @@ pluralkit.*.conf
# Generated
logs/
.version
recipe.json
recipe.json
.docker-bin/

5
Dockerfile.bin Normal file
View File

@ -0,0 +1,5 @@
FROM alpine:latest
COPY /.docker-bin/__BINARY__ /bin/__BINARY__
CMD ["/bin/__BINARY__"]