diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index accd31e..44fc445 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download source - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install Crystal uses: crystal-lang/install-crystal@v1 - name: Install shards diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..d39f34d --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,45 @@ +name: Docker + +on: + push: + tags: + - 'v*' + +jobs: + publish-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Container Metadata + id: metadata + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository_owner }}/blahaj + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - name: Build and Push Container + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49c2361..512f40e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,7 @@ name: Release + on: workflow_dispatch + jobs: build_linux_static: runs-on: ubuntu-latest @@ -7,10 +9,10 @@ jobs: image: crystallang/crystal:latest-alpine steps: - name: Download source - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Retrieve version run: | - echo "::set-output name=VERSION::$(shards version)" + echo "VERSION=$(shards version)" >> "$GITHUB_OUTPUT" id: version - name: Build run: make static_mt @@ -26,7 +28,7 @@ jobs: runs-on: ubuntu-latest needs: build_linux_static steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v2 with: path: ./GH_ARTIFACTS diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f7cd4eb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM --platform=linux/amd64 crystallang/crystal:latest-alpine as builder + +WORKDIR /root/src +COPY . . +RUN shards build --production --no-debug --release -Dpreview_mt --static + + +FROM scratch +COPY --from=builder /root/src/bin/blahaj /usr/local/bin/blahaj +ENTRYPOINT [ "blahaj" ] diff --git a/README.md b/README.md index 6b4fc7e..ee7d377 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,12 @@ They are built & published by our lovely [actions](https://github.com/GeopJr/BLA Arch Linux users can install the [blahaj](https://aur.archlinux.org/packages/blahaj) (or the [blahaj-git](https://aur.archlinux.org/packages/blahaj-git)) AUR package. +### Docker + +``` +docker run --rm -it --name blahaj ghcr.io/geopjr/blahaj -h +``` + ### Building #### Dependencies