-
Notifications
You must be signed in to change notification settings - Fork 53
93 lines (87 loc) · 2.92 KB
/
rpm.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
name: RPM
on:
pull_request:
paths:
- .github/workflows/rpm.yml
- Dockerfile.rpm
- amqproxy.spec
- shard.lock
- src/**
push:
branches:
- main
tags:
- v*
paths:
- .github/workflows/rpm.yml
- Dockerfile.rpm
- amqproxy.spec
- shard.lock
- src/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_rpm:
name: Build RPM
strategy:
matrix:
os: ['fedora-37']
runs-on: ubuntu-latest
concurrency: ${{ github.workflow }}-depot
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate version string
run: |
last_tag=$(git describe --tags --abbrev=0)
version=$(cut -d- -f1 <<< ${last_tag:1})
pre_release=$(cut -d- -f2 <<< $last_tag)
if [ -n "$pre_release" ]
then version=$version~${pre_release//./}
fi
git_describe=$(git describe --tags)
post_release=${git_describe//$last_tag/}
post_release=${post_release:1}
post_release=${post_release//-/.}
if [ -n "$post_release" ]
then version=$version^${post_release}
fi
echo "version=$version" >> $GITHUB_ENV
# The depot CLI still needs to be available in your workflow
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build deb package
uses: docker/build-push-action@v5
with:
cache-from: type=gha,scope=rpm-${{ matrix.os }}
cache-to: type=gha,mode=max,scope=rpm-${{ matrix.os }}
file: Dockerfile.rpm
platforms: linux/amd64,linux/arm64
build-args: |
build_image=84codes/crystal:1.6.2-${{ matrix.os }}
version=${{ env.version }}
outputs: RPMS
- uses: actions/upload-artifact@v4
name: Upload artifact
with:
name: rpm-packages
path: RPMS
- name: Upload to Packagecloud
run: |
set -eux
curl -fsSO -u "${{ secrets.packagecloud_token }}:" https://packagecloud.io/api/v1/distributions.json
ID=$(echo "${{ matrix.os }}" | cut -d- -f1)
VERSION_ID=$(echo "${{ matrix.os }}" | cut -d- -f2)
DIST_ID=$(jq ".rpm[] | select(.index_name == \"${ID}\").versions[] | select(.index_name == \"${VERSION_ID}\").id" distributions.json)
for PKG_FILE in $(find RPMS -name "*.rpm" | sort -u -t/ -k3)
do 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/${{ github.repository }}/packages.json
done
if: startsWith(github.ref, 'refs/tags/v')