Skip to content

Message deduplication #4015

Message deduplication

Message deduplication #4015

Workflow file for this run

name: Debian packages
on:
pull_request:
paths:
- .github/workflows/deb.yml
- Makefile
- Dockerfile.deb
- build/deb
- shard.lock
- src/**
- static/**
- views/**
- openapi/**
- debian/**
push:
branches:
- main
tags:
- v*
paths:
- .github/workflows/deb.yml
- Dockerfile.deb
- Makefile
- build/deb
- shard.lock
- src/**
- static/**
- views/**
- openapi/**
- debian/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_deb:
name: Build
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04, debian-12, debian-11]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate version string
run: |
git_describe=$(git describe --tags)
echo "version=${git_describe:1}" >> $GITHUB_ENV
- uses: depot/setup-action@v1
- uses: depot/build-push-action@v1
with:
file: Dockerfile.deb
platforms: linux/amd64,linux/arm64
pull: true
build-args: |
build_image=84codes/crystal:latest-${{ matrix.os }}
version=${{ env.version }}
DEB_BUILD_OPTIONS="parallel=1"
outputs: builds
- uses: actions/upload-artifact@v4
name: Upload artifact
with:
name: deb-packages-${{ matrix.os }}
path: builds
- name: Upload to Packagecloud
run: |
set -eux
ID=$(cut -d- -f1 <<< ${{ matrix.os }})
VERSION_ID=$(cut -d- -f2 <<< ${{ matrix.os }})
if [ "$ID" = "debian" ]
then VERSION_ID=${VERSION_ID}.0
fi
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
DIST_ID=$(jq ".deb[] | select(.index_name == \"${ID}\").versions[] | select(.version_number == \"${VERSION_ID}\").id" distributions.json)
for f in $(find builds -name "*.ddeb"); do mv -- "$f" "${f%.ddeb}.deb"; done
for PKG_FILE in $(find builds -name "*.deb")
do curl -u "${{ secrets.packagecloud_token }}:" -XPOST --no-progress-meter \
-F "package[distro_version_id]=${DIST_ID}" \
-F "package[package_file]=@${PKG_FILE}" \
https://packagecloud.io/api/v1/repos/${{ github.repository }}/packages.json
done
if: startsWith(github.ref, 'refs/tags/v')
- name: Upload to Packagecloud head repo
run: |
set -eux
ID=$(cut -d- -f1 <<< ${{ matrix.os }})
VERSION_ID=$(cut -d- -f2 <<< ${{ matrix.os }})
if [ "$ID" = "debian" ]
then VERSION_ID=${VERSION_ID}.0
fi
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
DIST_ID=$(jq ".deb[] | select(.index_name == \"${ID}\").versions[] | select(.version_number == \"${VERSION_ID}\").id" distributions.json)
for f in $(find builds -name "*.ddeb"); do mv -- "$f" "${f%.ddeb}.deb"; done
for PKG_FILE in $(find builds -name "*.deb")
do curl -u "${{ secrets.packagecloud_token }}:" -XPOST --no-progress-meter \
-F "package[distro_version_id]=${DIST_ID}" \
-F "package[package_file]=@${PKG_FILE}" \
https://packagecloud.io/api/v1/repos/${{ github.repository }}-head/packages.json
done
if: github.event_name != 'pull_request'