Skip to content

Commit adbfb7f

Browse files
committed
Add composite action to upload Debian artifacts to Artifactory
This action parses a .changes file and uploads associated Debian source and binary artifacts to a specified Artifactory repository. It supports provenance tagging, architecture detection, and metadata validation. Includes setup for JFrog CLI and dynamic property assignment for APT-compatible publishing. Signed-off-by: VISHAL KUMAR <viskuma@qti.qualcomm.com>
1 parent edd7673 commit adbfb7f

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

upload/action.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: "Upload Debian to Artifactory"
2+
description: "Uploads Debian artifacts from a .changes file to Artifactory"
3+
inputs:
4+
server_url:
5+
description: "Artifactory server URL (e.g. https://qartifactory.qualcomm.com)"
6+
required: true
7+
default: "https://qartifactory.qualcomm.com"
8+
target_base_repo:
9+
description: "Target repo name (e.g. deb-local or deb-remote)"
10+
required: true
11+
changes_path:
12+
description: "Path to .changes file with sources and binaries to upload"
13+
required: true
14+
provenance_info:
15+
description: "Overrides and extra artifactory properties to set on target files."
16+
required: true
17+
default: "{}"
18+
secret:
19+
description: "Artifactory token"
20+
required: true
21+
component:
22+
description: "Component name for the package"
23+
required: false
24+
default: "main"
25+
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Install prerequisites
30+
shell: bash
31+
run: |
32+
SUDO=sudo
33+
if [ `id -u` = 0 ]; then
34+
SUDO=""
35+
fi
36+
$SUDO apt update
37+
$SUDO apt install -y devscripts dctrl-tools jq
38+
39+
- name: Setup JFrog CLI
40+
uses: jfrog/setup-jfrog-cli@v4
41+
with:
42+
version: 1.54.0
43+
44+
- name: Configure JFrog server
45+
shell: bash
46+
env:
47+
SERVER_URL: ${{ inputs.server_url }}
48+
TOKEN: ${{ inputs.secret }}
49+
run: |
50+
jf c add artifactory-server \
51+
--url "$SERVER_URL" \
52+
--access-token "$TOKEN" \
53+
--interactive=false
54+
55+
- name: Parse .changes and provenance
56+
shell: bash
57+
env:
58+
CHANGES_PATH: ${{ inputs.changes_path }}
59+
PROVENANCE_INFO: ${{ inputs.provenance_info }}
60+
run: |
61+
set -euo pipefail
62+
CHANGES_DIR="$(dirname "$CHANGES_PATH")"
63+
CHANGES_FILE="$(basename "$CHANGES_PATH")"
64+
cd "$CHANGES_DIR"
65+
66+
SUITE="$(grep-dctrl -ns Distribution . "$CHANGES_FILE")"
67+
SOURCE_PKG="$(grep-dctrl -ns Source . "$CHANGES_FILE")"
68+
69+
ALL_FILES=$(grep-dctrl -nsFiles . "$CHANGES_FILE" | awk '{print $5}' | tr '\n' ' ')
70+
71+
COMPONENT=${{ inputs.component }}
72+
73+
BASE_PROPS="deb.distribution=${SUITE};deb.component=${COMPONENT}"
74+
for key in $(echo "$PROVENANCE_INFO" | jq -r 'keys[]'); do
75+
val=$(echo "$PROVENANCE_INFO" | jq -r --arg k "$key" '.[$k]')
76+
BASE_PROPS="${BASE_PROPS};${key}=${val}"
77+
done
78+
79+
echo "ALL_FILES=$ALL_FILES" >> $GITHUB_ENV
80+
echo "SOURCE_PKG=$SOURCE_PKG" >> $GITHUB_ENV
81+
echo "BASE_PROPS=$BASE_PROPS" >> $GITHUB_ENV
82+
83+
- name: Upload all artifacts with architecture detection
84+
shell: bash
85+
env:
86+
ALL_FILES: ${{ env.ALL_FILES }}
87+
BASE_PROPS: ${{ env.BASE_PROPS }}
88+
TARGET_PATH: ${{ inputs.target_base_repo }}
89+
SOURCE_PKG: ${{ env.SOURCE_PKG }}
90+
run: |
91+
for f in $ALL_FILES; do
92+
PROPS="$BASE_PROPS"
93+
if [[ "$f" =~ _arm64\.deb$ || "$f" =~ _arm64\.ddeb$ ]]; then
94+
PROPS="${PROPS};deb.architecture=arm64"
95+
elif [[ "$f" =~ _amd64\.deb$ || "$f" =~ _amd64\.ddeb$ ]]; then
96+
PROPS="${PROPS};deb.architecture=amd64"
97+
fi
98+
99+
jf rt upload --server-id=artifactory-server \
100+
--target-props "${PROPS}" \
101+
"$f" "$TARGET_PATH"/pool/"$SOURCE_PKG"/
102+
done

0 commit comments

Comments
 (0)