-
Notifications
You must be signed in to change notification settings - Fork 3.5k
105 lines (87 loc) · 3.53 KB
/
check-apk-valid-version.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
name: Check APK compatible version/release
on:
pull_request_target:
types: [opened, synchronize, converted_to_draft, ready_for_review, edited]
jobs:
build:
name: Check autorelease deprecation
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Setup APK
run: |
wget -O $GITHUB_WORKSPACE/apk https://buildbot.aparcar.org/apk.static
chmod +x $GITHUB_WORKSPACE/apk
- name: Determine changed packages
run: |
RET=0
INCOMPATIBLE_VERSION=""
# only detect packages with changes
PKG_ROOTS=$(find . -name Makefile | \
grep -v ".*/src/Makefile" | \
sed -e 's@./\(.*\)/Makefile@\1/@')
CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH...)
for ROOT in $PKG_ROOTS; do
for CHANGE in $CHANGES; do
if [[ "$CHANGE" == "$ROOT"* ]]; then
PKG_RELEASE=$(grep -E '^PKG_RELEASE' "$ROOT/Makefile" | cut -f 2 -d '=')
if [ -n "$PKG_RELEASE" ]; then
if [[ "$PKG_RELEASE" == '^[0-9]+$' ]]; then
echo "PKG_RELEASE is not an integer"
INCOMPATIBLE_VERSION+=" $ROOT"
break
fi
fi
PKG_VERSION=$(grep -E '^PKG_VERSION' "$ROOT/Makefile" | cut -f 2 -d '=')
if [ -n "$PKG_VERSION" ]; then
if [[ $($GITHUB_WORKSPACE/apk version --check "$PKG_VERSION") -ne "" ]]; then
echo "PKG_VERSION is not compatible"
INCOMPATIBLE_VERSION+=" $ROOT"
fi
fi
fi
done
done
echo "Incompatible versions: $INCOMPATIBLE_VERSION"
if [ -n "$INCOMPATIBLE_VERSION" ]; then
RET=1
cat > "$GITHUB_WORKSPACE/pr_comment.md" << EOF
OpenWrt will change to the APK package manager which requires
deterministic verisons. Please make sure that **PKG_VERSION**
follows [Semantic Versioning](https://semver.org) or more specifically,
the [APK version scheme](https://gitlab.alpinelinux.org/alpine/apk-tools/-/blob/master/doc/apk-package.5.scd?ref_type=heads#L47).
If the version is based on a date, please use dots instead of dashes, i.e. **24.01.01**.
The **PKG_RELEASE** should be an integer and not contain any letters or special characters.
EOF
fi
for ROOT in $INCOMPATIBLE_VERSION; do
echo " - ${ROOT}Makefile" >> "$GITHUB_WORKSPACE/pr_comment.md"
done
exit $RET
- name: Find Comment
uses: peter-evans/find-comment@v2
if: ${{ failure() }}
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ failure() }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: "pr_comment.md"
edit-mode: replace