Skip to content

Commit ad8ca90

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 ad8ca90

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

upload/action.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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.pe.jfrog.io)"
6+
required: false
7+
default: "https://qartifactory.pe.jfrog.io"
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: false
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: latest
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+
COMPONENT: ${{ inputs.component }}
61+
run: |
62+
set -euo pipefail
63+
CHANGES_DIR="$(dirname "$CHANGES_PATH")"
64+
CHANGES_FILE="$(basename "$CHANGES_PATH")"
65+
cd "$CHANGES_DIR"
66+
67+
SUITE="$(grep-dctrl -ns Distribution . "$CHANGES_FILE")"
68+
SOURCE_PKG="$(grep-dctrl -ns Source . "$CHANGES_FILE")"
69+
ALL_FILES=$(grep-dctrl -nsFiles . "$CHANGES_FILE" | awk '{print $5}' | tr '\n' ' ')
70+
71+
PROPS="deb.distribution=${SUITE};deb.component=${COMPONENT}"
72+
for key in $(echo "$PROVENANCE_INFO" | jq -r 'keys[]'); do
73+
val=$(echo "$PROVENANCE_INFO" | jq -r --arg k "$key" '.[$k]')
74+
PROPS="${PROPS};${key}=${val}"
75+
done
76+
77+
echo "ALL_FILES=$ALL_FILES" >> $GITHUB_ENV
78+
echo "SOURCE_PKG=$SOURCE_PKG" >> $GITHUB_ENV
79+
echo "PROPS=$PROPS" >> $GITHUB_ENV
80+
81+
- name: Upload all artifacts with architecture detection
82+
shell: bash
83+
env:
84+
TARGET_BASE_REPO: ${{ inputs.target_base_repo }}
85+
run: |
86+
TARGET_DIR="$TARGET_BASE_REPO/pool/$SOURCE_PKG/"
87+
for f in $ALL_FILES; do
88+
if [[ "$f" =~ _arm64\.deb$ || "$f" =~ _arm64\.ddeb$ ]]; then
89+
PROPS="${PROPS};deb.architecture=arm64"
90+
elif [[ "$f" =~ _amd64\.deb$ || "$f" =~ _amd64\.ddeb$ ]]; then
91+
PROPS="${PROPS};deb.architecture=amd64"
92+
fi
93+
echo "Uploading $f with props: $PROPS"
94+
jf rt upload --server-id=artifactory-server \
95+
--target-props "${PROPS}" \
96+
"$f" "$TARGET_DIR"
97+
done

0 commit comments

Comments
 (0)