-
-
Notifications
You must be signed in to change notification settings - Fork 25
156 lines (142 loc) · 5.46 KB
/
autobuild.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# for each folder in anda/
# generate a new workflow for each folder in anda/
name: Automatically build packages
on:
push:
paths:
- anda/**
branches:
- f38
pull_request:
branches:
- f38
merge_group:
branches:
- f38
workflow_dispatch:
workflow_call:
jobs:
manifest:
runs-on: ubuntu-latest
outputs:
build_matrix: ${{ steps.generate_build_matrix.outputs.build_matrix }}
container:
image: ghcr.io/terrapkg/builder:f38
options: --cap-add=SYS_ADMIN --privileged
steps:
- name: Set workspace as safe
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Generate build matrix
id: generate_build_matrix
run: anda ci >> $GITHUB_OUTPUT
build:
needs: manifest
strategy:
matrix:
pkg: ${{ fromJson(needs.manifest.outputs.build_matrix) }}
version: ["38"]
fail-fast: false
runs-on: ${{ matrix.pkg.arch == 'aarch64' && 'ARM64' || 'ubuntu-latest' }}
container:
image: ghcr.io/terrapkg/builder:f38
options: --cap-add=SYS_ADMIN --privileged
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up git repository
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Cache buildroot
id: br-cache
uses: actions/cache@v3
with:
path: /var/cache
key: ${{ runner.os }}-br-${{ matrix.version }}-${{ matrix.pkg.arch }}-${{ matrix.pkg.pkg }}
- name: Include custom build template instead of package default
run: |
cp -v anda/mock-configs/terra.tpl /etc/mock/templates/terra.tpl
- name: Build with Andaman
run: anda build ${{ matrix.pkg.pkg }} --package rpm -c anda/mock-configs/terra-${{ matrix.version }}-${{ matrix.pkg.arch }}.cfg
- name: Generating artifact name
id: art
run: |
NAME=${{ matrix.pkg.pkg }}-${{ matrix.pkg.arch }}-${{ matrix.version }}
x=${NAME//\//@}
echo "name=$x" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.art.outputs.name }}
path: anda-build/rpm/rpms/*
- name: Upload packages to subatomic
if: github.event_name == 'push'
run: |
subatomic-cli upload --prune \
--server https://subatomic.fyralabs.com \
--token ${{ secrets.SUBATOMIC_TOKEN }} \
terra${{ matrix.version }} anda-build/rpm/rpms/*
- name: Notify Madoguchi (Success)
if: success() && github.event_name == 'push'
run: ./.github/workflows/mg.sh true ${{matrix.pkg.pkg}} ${{matrix.version}} ${{matrix.pkg.arch}} ${{github.run_id}} ${{secrets.MADOGUCHI_JWT}}
- name: Notify Madoguchi (Failure)
if: ( cancelled() || failure() ) && github.event_name == 'push'
run: ./.github/workflows/mg.sh false ${{matrix.pkg.pkg}} ${{matrix.version}} ${{matrix.pkg.arch}} ${{github.run_id}} ${{secrets.MADOGUCHI_JWT}}
- name: Lint RPMs and SRPMs
id: lint
if: success()
run: |
echo 'LINT_ERR=false' >> $GITHUB_ENV
rpmlint anda-build/ > rpmlint.txt || f=1
if [[ $f -eq 1 ]]; then
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "ESC_LINT_OUT<<$EOF" >> $GITHUB_ENV
cat rpmlint.txt | sed 's/`/\\`/g' | sed 's/"/\"/g' >> $GITHUB_ENV
echo $EOF >> $GITHUB_ENV
echo "lint_out<<$EOF" >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
cat rpmlint.txt >> $GITHUB_ENV
echo '```' >> $GITHUB_ENV
echo $EOF >> $GITHUB_ENV
echo 'LINT_ERR=true' >> $GITHUB_ENV
fi
- name: Try to install package
id: dnf
if: success()
run: |
echo 'INSTALL_ERR=false' >> $GITHUB_ENV
touch out
for f in anda-build/rpm/rpms/*.rpm; do
dnf in --downloadonly -y $f > $f.dnfout.txt 2>&1 || fail=1
if [[ $fail -eq 1 ]]; then
echo "### $f" >> out
echo '```' >> out
cat $f.dnfout.txt >> out
echo '```' >> out
echo >> out
echo 'INSTALL_ERR=true' >> $GITHUB_ENV
fi
done
cat out
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "ESC_DNF_OUT<<$EOF" >> $GITHUB_ENV
cat out | sed 's/`/\\`/g' | sed 's/"/\"/g' >> $GITHUB_ENV
echo $EOF >> $GITHUB_ENV
echo "dnf_out<<$EOF" >> $GITHUB_ENV
cat out >> $GITHUB_ENV
echo $EOF >> $GITHUB_ENV
- name: Generate RPMLint/DNF summary
if: success()
run: |
# Remind me to make all of this not weird later ~ lleyton
if [[ $LINT_ERR == "true" ]]; then
echo -e "## ❌ Lint: [${{matrix.pkg.pkg}} (${{matrix.pkg.arch}})](https://github.com/terrapkg/packages/actions/runs/${{github.run_id}})\n" >> $GITHUB_STEP_SUMMARY
echo -e "```\n${{ env.ESC_LINT_OUT }}\n```\n" >> $GITHUB_STEP_SUMMARY
fi
if [[ $INSTALL_ERR == "true" ]]; then
echo -e "## ❌ DNF: [${{matrix.pkg.pkg}} (${{matrix.pkg.arch}})](https://github.com/terrapkg/packages/actions/runs/${{github.run_id}})\n" >> $GITHUB_STEP_SUMMARY
echo "${{ env.ESC_DNF_OUT }}" >> $GITHUB_STEP_SUMMARY
fi