2019-09-08 14:38:25 +00:00
|
|
|
name: Publish consumable Docker images
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags: ['*.*.*']
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
compile:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
arch:
|
|
|
|
- x86_64-unknown-linux-musl
|
|
|
|
- x86_64-unknown-linux-gnu
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- run: cargo install cross
|
|
|
|
- name: compile for specific target
|
|
|
|
env: { arch: '${{ matrix.arch }}' }
|
|
|
|
run: |
|
|
|
|
cross build --target ${{ matrix.arch }} --release
|
|
|
|
# leave only the executable file
|
|
|
|
rm -rd target/${{ matrix.arch }}/release/{*/*,*.d,*.rlib,.fingerprint}
|
|
|
|
find . -empty -delete
|
|
|
|
- uses: actions/upload-artifact@master
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.arch }}
|
|
|
|
path: target/${{ matrix.arch }}/release
|
|
|
|
|
|
|
|
docker:
|
|
|
|
name: Build and publish docker images
|
|
|
|
needs: compile
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2019-09-09 00:15:51 +00:00
|
|
|
tag:
|
|
|
|
- alpine
|
|
|
|
- slim
|
|
|
|
- debian
|
|
|
|
- glibc-busybox
|
|
|
|
- musl-busybox
|
|
|
|
- musl-distroless
|
|
|
|
- glibc-distroless
|
|
|
|
- glibc
|
|
|
|
- musl
|
2019-09-08 14:38:25 +00:00
|
|
|
include:
|
2019-09-09 09:45:55 +00:00
|
|
|
- { tag: alpine, base-image: alpine, arch: x86_64-unknown-linux-musl, plugin: true }
|
|
|
|
- { tag: slim, base-image: 'debian:stable-slim', arch: x86_64-unknown-linux-gnu, plugin: true }
|
|
|
|
- { tag: debian, base-image: debian, arch: x86_64-unknown-linux-gnu, plugin: true }
|
|
|
|
- { tag: glibc-busybox, base-image: 'busybox:glibc', arch: x86_64-unknown-linux-gnu, use-patch: true }
|
|
|
|
- { tag: musl-busybox, base-image: 'busybox:musl', arch: x86_64-unknown-linux-musl, }
|
|
|
|
- { tag: musl-distroless, base-image: 'gcr.io/distroless/static', arch: x86_64-unknown-linux-musl, }
|
|
|
|
- { tag: glibc-distroless, base-image: 'gcr.io/distroless/cc', arch: x86_64-unknown-linux-gnu, use-patch: true }
|
|
|
|
- { tag: glibc, base-image: scratch, arch: x86_64-unknown-linux-gnu, }
|
|
|
|
- { tag: musl, base-image: scratch, arch: x86_64-unknown-linux-musl, }
|
2019-09-08 14:38:25 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- uses: actions/download-artifact@master
|
|
|
|
with: { name: '${{ matrix.arch }}', path: target/release }
|
|
|
|
- name: Build and publish exact version
|
|
|
|
run: |
|
|
|
|
REGISTRY=${REGISTRY,,}; export TAG=${GITHUB_REF##*/}-${{ matrix.tag }};
|
2019-09-08 18:29:52 +00:00
|
|
|
export NU_BINS=target/release/$( [ ${{ matrix.plugin }} = true ] && echo nu* || echo nu )
|
2019-09-09 09:45:55 +00:00
|
|
|
export PATCH=$([ ${{ matrix.use-patch }} = true ] && echo .${{ matrix.tag }} || echo '')
|
2019-09-08 22:41:58 +00:00
|
|
|
chmod +x $NU_BINS
|
2019-09-08 14:38:25 +00:00
|
|
|
|
|
|
|
echo ${{ secrets.DOCKER_REGISTRY }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
|
|
|
docker-compose --file docker/docker-compose.package.yml build
|
|
|
|
docker-compose --file docker/docker-compose.package.yml push # exact version
|
|
|
|
env:
|
|
|
|
BASE_IMAGE: ${{ matrix.base-image }}
|
|
|
|
REGISTRY: docker.pkg.github.com/${{ github.repository }}
|
|
|
|
|
|
|
|
#region semantics tagging
|
|
|
|
- name: Retag and push without suffixing version
|
|
|
|
run: |
|
|
|
|
VERSION=${GITHUB_REF##*/}
|
|
|
|
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${{ matrix.tag }}
|
|
|
|
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%%.*}-${{ matrix.tag }}
|
|
|
|
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%.*}-${{ matrix.tag }}
|
|
|
|
docker push ${REGISTRY,,}/nu:${VERSION%.*}-${{ matrix.tag }} # latest patch
|
|
|
|
docker push ${REGISTRY,,}/nu:${VERSION%%.*}-${{ matrix.tag }} # latest features
|
|
|
|
docker push ${REGISTRY,,}/nu:${{ matrix.tag }} # latest version
|
|
|
|
env: { REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' }
|
|
|
|
- name: Retag and push debian as latest
|
|
|
|
if: matrix.tag == 'debian'
|
|
|
|
run: |
|
|
|
|
VERSION=${GITHUB_REF##*/}
|
|
|
|
docker tag ${REGISTRY,,}/nu:${{ matrix.tag }} ${REGISTRY,,}/nu:latest
|
|
|
|
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%.*}
|
|
|
|
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION%%.*}
|
|
|
|
docker tag ${REGISTRY,,}/nu:${VERSION}-${{ matrix.tag }} ${REGISTRY,,}/nu:${VERSION}
|
|
|
|
docker push ${REGISTRY,,}/nu:${VERSION} # exact version
|
|
|
|
docker push ${REGISTRY,,}/nu:${VERSION%%.*} # latest features
|
|
|
|
docker push ${REGISTRY,,}/nu:${VERSION%.*} # latest patch
|
|
|
|
docker push ${REGISTRY,,}/nu:latest # latest version
|
|
|
|
env: { REGISTRY: 'docker.pkg.github.com/${{ github.repository }}' }
|
|
|
|
#endregion semantics tagging
|