-
Notifications
You must be signed in to change notification settings - Fork 35
110 lines (105 loc) · 3.59 KB
/
deb.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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-22.04, ubuntu-20.04, 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:1.9.2-${{ matrix.os }}
version=${{ env.version }}
DEB_BUILD_OPTIONS="parallel=1"
outputs: builds
- uses: actions/upload-artifact@v3
name: Upload artifact
with:
name: deb-packages
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'