Skip to content

Bump GitHub actions #175

Bump GitHub actions

Bump GitHub actions #175

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
spec:
name: Spec
runs-on: ubuntu-latest
container: 84codes/crystal:latest-alpine
steps:
- uses: actions/checkout@v4
- name: Shards install
run: shards install --production
- name: Spec
run: crystal spec --no-color --order random
format:
name: Formatting
runs-on: ubuntu-latest
container: 84codes/crystal:latest-alpine
steps:
- uses: actions/checkout@v4
- name: Format check
run: crystal tool format --check
lint:
name: Lint/Ameba
runs-on: ubuntu-latest
container: 84codes/crystal:latest-alpine
steps:
- name: Install make
run: apk add --no-cache make yaml-dev
- name: Checkout
uses: actions/checkout@v4
- name: Shards install
run: shards install
- name: Spec
run: bin/ameba --no-color
docker:
name: Docker container
needs: [spec, format, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: meta
with:
images: 84codes/sparoid
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=tag
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push container
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
cache-from: type=gha
cache-to: type=gha,mode=max
deb:
name: Deb package
needs: [spec, format, lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, debian-10, debian-11, debian-12]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
name: Build
with:
file: deb.dockerfile
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
build_image=84codes/crystal:latest-${{ matrix.os }}
outputs: builds
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.arch }}-${{ matrix.os }}
path: builds/
- name: Upload to PackageCloud
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
set -eux
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
PKG_FILE=$(find builds -name "*.deb" | head -1)
ID=$(echo $PKG_FILE | cut -d/ -f2)
VERSION_CODENAME=$(echo $PKG_FILE | cut -d/ -f3)
DIST_ID=$(jq ".deb[] | select(.index_name == \"${ID}\").versions[] | select(.index_name == \"${VERSION_CODENAME}\").id" distributions.json)
curl -fsS -u "${{ secrets.packagecloud_token }}:" -XPOST \
-F "package[distro_version_id]=${DIST_ID}" \
-F "package[package_file]=@${PKG_FILE}" \
https://packagecloud.io/api/v1/repos/cloudamqp/sparoid/packages.json
rpm:
name: RPM package
needs: [spec, format, lint]
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
os: [fedora-39, fedora-40]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
file: rpm.dockerfile
platforms: linux/${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
build_image=84codes/crystal:latest-${{ matrix.os }}
outputs: builds
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: rpm-${{ matrix.arch }}-${{ matrix.os }}
path: builds/
- name: Upload to PackageCloud
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
set -eux
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
ID=$(echo ${{ matrix.os }} | cut -d- -f1)
VR=$(echo ${{ matrix.os }} | cut -d- -f2)
DIST_ID=$(jq ".rpm[] | select(.index_name == \"${ID}\").versions[] | select(.index_name == \"${VR}\").id" distributions.json)
find builds -name "*.rpm" | xargs -i \
curl -fsS -u "${{ secrets.packagecloud_token }}:" -XPOST \
-F "package[distro_version_id]=${DIST_ID}" \
-F "package[package_file]=@{}" \
https://packagecloud.io/api/v1/repos/cloudamqp/sparoid/packages.json
tar:
runs-on: ubuntu-latest
needs: [spec, format, lint]
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Build tar package
uses: docker/build-push-action@v6
with:
file: tar.dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: tar
path: ./*.tar.gz
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
files: '*.tar.gz'
fail_on_unmatched_files: true