-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
123 lines (119 loc) · 5.1 KB
/
action.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
111
112
113
114
115
116
117
118
119
120
121
122
123
name: 'pkgbuild info action'
description: 'tries to determine pkgbuild version information'
inputs:
pkgbuild:
description: file to look into
required: false
default: PKGBUILD
arm-runs-on:
description: Builder to use when building on arm
required: false
default: buildjet-2vcpu-ubuntu-2204-arm
runs:
using: "composite"
steps:
- name: install some tools
shell: bash
run: |
if [ $(grep ^ID= /etc/os-release | cut -d'=' -f2) == 'ubuntu' ]; then
exit 0
else
pacman -Syy github-cli --noconfirm
fi
- id: version
shell: bash
run: |
VERSION=$(cat ${{ inputs.pkgbuild || 'PKGBUILD' }} | grep ^pkgver= | sed -e 's/^pkgver=//' | awk '{print $1}')-$(cat ${{ matrix.pkgbuild || 'PKGBUILD' }} | grep ^pkgrel= | sed -e 's/^pkgrel=//' | awk '{print $1}')
EPOCH=$(cat ${{ matrix.pkgbuild || 'PKGBUILD' }} | { grep ^epoch= || true; } | sed -e 's/^epoch=//' | awk '{print $1}')
echo "version<<EOF" >> "${GITHUB_OUTPUT}"
echo "${EPOCH:+${EPOCH}__}${VERSION}" >> "${GITHUB_OUTPUT}"
echo "EOF" >> "${GITHUB_OUTPUT}"
- id: archs
shell: bash
run: |
echo "archs=$(cat ${{ matrix.pkgbuild || 'PKGBUILD' }} | grep ^arch= | sed -e 's/^arch=(\(.*\))/\1/')" >>$GITHUB_OUTPUT
echo "arch=$(uname -m)" >>$GITHUB_OUTPUT
- id: branches
shell: bash
run: |
echo ${{ github.token }} | gh auth login --with-token
branches=()
gh release list --limit 3 --repo ${{ github.repository }} | grep '^stable-${{ steps.version.outputs.version }}' || branches+=("\"stable\"")
gh release list --limit 3 --repo ${{ github.repository }} | grep '^testing-${{ steps.version.outputs.version }}' || branches+=("\"testing\"")
gh release list --limit 3 --repo ${{ github.repository }} | grep '^unstable-${{ steps.version.outputs.version }}' || branches+=("\"unstable\"")
printf -v joined '%s,' "${branches[@]}"
branches="${joined%,}"
if [ "${branches}" != "" ]; then
echo "branches=[${branches}]" >>$GITHUB_OUTPUT
fi
- id: python
shell: bash
run: |
cat ${{ matrix.pkgbuild || 'PKGBUILD' }} | grep -E 'python setup.py|python -m' && echo "python=true" >>$GITHUB_OUTPUT || echo "python=false" >>$GITHUB_OUTPUT
- id: aarch64
shell: bash
if: ${{ contains(steps.archs.outputs.archs, 'aarch64') }}
run: echo "aarch64=true" >>$GITHUB_OUTPUT
- id: x86_64
shell: bash
if: ${{ contains(steps.archs.outputs.archs, 'x86_64') }}
run: echo "x86_64=true" >>$GITHUB_OUTPUT
- id: any
shell: bash
if: ${{ contains(steps.archs.outputs.archs, 'any') }}
run: echo "any=true" >>$GITHUB_OUTPUT
- id: fits-any
shell: bash
if: steps.any.outputs.any == 'true' && steps.archs.outputs.arch == 'x86_64'
run: echo "fits=true" >>$GITHUB_OUTPUT
- id: fits-x86_64
shell: bash
if: steps.x86_64.outputs.x86_64 == 'true' && steps.archs.outputs.arch == 'x86_64'
run: echo "fits=true" >>$GITHUB_OUTPUT
- id: fits-aarch64
shell: bash
if: steps.aarch64.outputs.aarch64 == 'true' && steps.archs.outputs.arch == 'aarch64'
run: echo "fits=true" >>$GITHUB_OUTPUT
- id: runs-x86_64
shell: bash
if: steps.any.outputs.any == 'true' || (steps.x86_64.outputs.x86_64 == 'true' && steps.aarch64.outputs.aarch64 != 'true')
run: echo "runs-on=[\"ubuntu-latest\"]" >>$GITHUB_OUTPUT
- id: runs-aarch64
shell: bash
if: steps.x86_64.outputs.x86_64 != 'true' && steps.aarch64.outputs.aarch64 == 'true'
run: echo "runs-on=[\"${{ inputs.arm-runs-on }}\"]" >>$GITHUB_OUTPUT
- id: runs-both
shell: bash
if: steps.x86_64.outputs.x86_64 == 'true' && steps.aarch64.outputs.aarch64 == 'true'
run: echo "runs-on=[\"${{ inputs.arm-runs-on }}\", \"ubuntu-latest\"]" >>$GITHUB_OUTPUT
outputs:
version:
value: ${{ steps.version.outputs.version }}
description: the current pkgbuild version
exists:
value: ${{ steps.exists.outputs.exists }}
description: wether the release already exists
fits:
description: if package can be built on current architecture
value: ${{ steps.fits-any.outputs.fits || steps.fits-x86_64.outputs.fits || steps.fits-aarch64.outputs.fits }}
system-arch:
value: ${{ steps.archs.outputs.arch }}
description: the runners architecture
aarch64:
value: ${{ steps.aarch64.outputs.aarch64 }}
description: if the package can be built for aarch64
x86_64:
value: ${{ steps.x86_64.outputs.x86_64 }}
description: if the package can be built for x86_64
any:
value: ${{ steps.any.outputs.any }}
description: if the package can be built for any architecture
runs-on:
value: ${{ steps.runs-both.outputs.runs-on || steps.runs-x86_64.outputs.runs-on || steps.runs-aarch64.outputs.runs-on }}
description: runner array
branches:
value: ${{ steps.branches.outputs.branches || '' }}
description: array of branches that have no matching release yet
python:
value: ${{ steps.python.outputs.python }}
description: wether this package is python-based