Skip to content

Commit 052d8f4

Browse files
arrowplumCopilot
andauthored
INFRA-128 upload artifacts (#23)
* feat(workflows): add reusable upload-artifacts workflow and supporting scripts * feat(workflows): add dry-run support to upload-artifacts entrypoint script * feat(workflows): add dry-run option to artifact upload workflow * fix: apply suggestions from code review Co-authored-by: Copilot <[email protected]> * fix(workflows): pin reusable_sign-artifacts workflow to specific commit (since it is now in main) * ci(workflows): add job to upload test artifacts in the upload-artifacts workflow --------- Co-authored-by: Copilot <[email protected]>
1 parent e98d5bd commit 052d8f4

File tree

10 files changed

+1070
-3
lines changed

10 files changed

+1070
-3
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Upload to JFrog Artifactory
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
project:
7+
description: JFrog Artifactory project name
8+
required: true
9+
type: string
10+
build-prefix:
11+
description: Prefix for the build name
12+
required: true
13+
type: string
14+
version:
15+
description: Version of the artifact to upload
16+
required: true
17+
type: string
18+
artifactory-url:
19+
required: false
20+
description: JFrog Artifactory URL
21+
type: string
22+
default: https://aerospike.jfrog.io
23+
artifactory-oidc-provider-name:
24+
required: false
25+
description: OIDC provider name
26+
type: string
27+
default: gh-citrusleaf
28+
artifactory-oidc-audience:
29+
required: false
30+
description: OIDC audience
31+
type: string
32+
default: citrusleaf
33+
build-artifacts-name:
34+
description: Name of downloaded/uploaded artifacts
35+
required: false
36+
type: string
37+
default: build-artifacts
38+
dry-run:
39+
description: Whether to run in dry-run mode. Dry-run mode will not upload any artifacts.
40+
required: false
41+
type: boolean
42+
default: false
43+
44+
permissions:
45+
contents: read
46+
packages: write
47+
id-token: write
48+
49+
jobs:
50+
upload:
51+
runs-on: ubuntu-22.04
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 0
57+
- name: Setup JFrog CLI
58+
uses: jfrog/setup-jfrog-cli@f748a0599171a192a2668afee8d0497f7c1069df # v4.5.6
59+
env:
60+
JF_URL: ${{ inputs.artifactory-url }}
61+
JF_PROJECT: ${{ inputs.project }}
62+
with:
63+
oidc-provider-name: ${{ inputs.artifactory-oidc-provider-name }}
64+
oidc-audience: ${{ inputs.artifactory-oidc-audience }}
65+
66+
- name: Check JFrog Configuration
67+
run: |
68+
jf c show
69+
jf rt ping
70+
- name: Download artifacts
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: ${{ inputs.build-artifacts-name }}
74+
path: ./build-artifacts
75+
76+
- name: Upload Artifacts
77+
shell: bash
78+
run: |
79+
chmod +x ${{ github.workspace }}/.github/workflows/upload-artifacts/entrypoint.sh
80+
dry_run_arg=""
81+
if [ "${{ inputs.dry-run }}" = "true" ]; then
82+
dry_run_arg="--dry-run"
83+
fi
84+
${{ github.workspace }}/.github/workflows/upload-artifacts/entrypoint.sh \
85+
"${{ inputs.project }}" \
86+
"${{ inputs.build-prefix }}" \
87+
"${{ inputs.version }}" \
88+
$dry_run_arg

.github/workflows/test_sign-artifacts-workflow.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ jobs:
1010
# In order to test the workflow in a subdirectory, we need to limit it to a specific ref.
1111
# This will require a secondary PR to clean up the conditional logic for the main branch.
1212
test-sign-workflow:
13-
if: github.head_ref == 'feature/INFRA-127-develop-sign-artifacts-workflow'
14-
uses: aerospike/shared-workflows/.github/workflows/reusable_sign-artifacts.yaml@feature/INFRA-127-develop-sign-artifacts-workflow
13+
uses: aerospike/shared-workflows/.github/workflows/reusable_sign-artifacts.yaml@e98d5bdf0034b78651a53729650aece75f85f96d # FIXME: pin to release on release of v1.1.0
1514
with:
1615
artifact-glob: tests/**/*.{deb,rpm}
1716
output-dir: signed-artifacts
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test Upload Workflow
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
packages: write
11+
12+
jobs:
13+
upload-test-gh-artifacts:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Upload Artifacts
19+
uses: actions/upload-artifact@v4
20+
with:
21+
name: build-artifacts
22+
path: tests/test-1.0-2.noarch.rpm
23+
# In order to test the workflow in a subdirectory, we need to limit it to a specific ref.
24+
# This will require a secondary PR to clean up the conditional logic for the main branch.
25+
test-upload-workflow:
26+
if: github.head_ref == 'feature/INFRA-128-upload-artifacts'
27+
uses: aerospike/shared-workflows/.github/workflows/reusable_upload-artifacts.yaml@feature/INFRA-128-upload-artifacts
28+
with:
29+
project: database
30+
build-prefix: test-upload-workflow
31+
version: v1.0.0
32+
artifactory-url: https://aerospike.jfrog.io
33+
artifactory-oidc-provider-name: gh-aerospike
34+
artifactory-oidc-audience: aerospike
35+
build-artifacts-name: build-artifacts
36+
37+
run-tests:
38+
runs-on: ubuntu-22.04
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
- name: Install dependencies
43+
run: |
44+
sudo apt-get update && sudo apt-get install dpkg-dev rpm -y
45+
- name: Test Entrypoint
46+
run: |
47+
.github/workflows/upload-artifacts/test-entrypoint.sh
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Upload to JFrog Artifactory Workflow
2+
3+
A reusable GitHub Actions workflow for uploading artifacts to JFrog Artifactory following best practices for repository naming and organization.
4+
5+
## Overview
6+
7+
This workflow uploads build artifacts to JFrog Artifactory. It automatically categorizes files by type and uploads them to the appropriate repositories:
8+
9+
- **DEB packages**`{project}-deb-dev-local`
10+
- **RPM packages**`{project}-rpm-dev-local`
11+
- **Generic files**`{project}-generic-dev-local`
12+
13+
The workflow processes artifacts from a `build-artifacts` directory and creates structured build artifacts before uploading.
14+
15+
### Debian/Ubuntu Structure
16+
17+
```text
18+
pool/
19+
├── bookworm/
20+
│ └── {package-name}/
21+
│ ├── {package-name}_version_debian12_arch.deb
22+
│ └── {package-name}_version_debian12_arch.deb.asc
23+
├── bullseye/
24+
│ └── {package-name}/
25+
│ └── {package-name}_version_debian11_arch.deb
26+
├── jammy/
27+
│ └── {package-name}/
28+
│ └── {package-name}_version_ubuntu22.04_arch.deb
29+
└── noble/
30+
└── {package-name}/
31+
└── {package-name}_version_ubuntu24.04_arch.deb
32+
```
33+
34+
### RPM/Yum Structure
35+
36+
```text
37+
repo/
38+
├── el8/
39+
│ ├── x86_64/
40+
│ │ ├── *.rpm
41+
│ │ └── repodata/
42+
│ └── aarch64/
43+
│ ├── *.rpm
44+
│ └── repodata/
45+
├── el9/
46+
│ └── …
47+
└── amzn2023/
48+
└── …
49+
```
50+
51+
## Inputs
52+
53+
| Input | Description | Required | Default |
54+
| -------------------------------- | ------------------------------------- | -------- | ---------------------------- |
55+
| `project` | JFrog Artifactory project name | Yes | - |
56+
| `build-prefix` | Prefix for the build name | Yes | - |
57+
| `version` | Version string for build info | Yes | - |
58+
| `artifactory-url` | JFrog Artifactory URL | No | `https://aerospike.jfrog.io` |
59+
| `artifactory-oidc-provider-name` | OIDC provider name for authentication | No | `gh-citrusleaf` |
60+
| `artifactory-oidc-audience` | OIDC audience for authentication | No | `citrusleaf` |
61+
| `build-artifacts-name` | Name of the artifacts to download | No | `build-artifacts` |
62+
| `dry-run` | Whether to run in dry-run mode | No | `false` |
63+
64+
## Example Usage
65+
66+
```yaml
67+
name: Upload to Artifactory
68+
on:
69+
workflow_dispatch:
70+
push:
71+
tags: ["v*"]
72+
73+
jobs:
74+
upload:
75+
uses: ./.github/workflows/reusable_upload-artifacts.yaml
76+
with:
77+
project: database
78+
build-prefix: database
79+
version: ${{ github.ref_name }}
80+
artifactory-url: https://aerospike.jfrog.io
81+
artifactory-oidc-provider-name: gh-citrusleaf
82+
artifactory-oidc-audience: citrusleaf
83+
build-artifacts-name: build-artifacts
84+
dry-run: false
85+
```
86+
87+
### Build Info Publishing
88+
89+
After uploading artifacts, the workflow publishes comprehensive build information:
90+
91+
- Environment variables
92+
- Git information
93+
- Dependencies
94+
- Build metadata
95+
96+
The workflow creates separate build info for each artifact type:
97+
98+
- `{build-prefix}-deb` for DEB packages
99+
- `{build-prefix}-rpm` for RPM packages
100+
- `{build-prefix}-generic` for generic files
101+
102+
## Prerequisites
103+
104+
- JFrog Artifactory instance with OIDC authentication configured
105+
- GitHub Actions with OIDC token access to Artifactory
106+
- Build artifacts available as downloadable artifacts
107+
108+
## Notes
109+
110+
- The workflow expects artifacts to be in a directory called `build-artifacts`
111+
- All uploads use the "DEV" environment level and "local" locator
112+
- Build info is published for each artifact type separately
113+
- The workflow processes DEB and RPM files and creates structured build artifacts before uploading
114+
- Generic files are uploaded directly without structured processing

0 commit comments

Comments
 (0)