Improve cacert upload check logic (#869) #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish ca-certificates | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- 'linux/ca-certificates/**' | |
- '.github/workflows/cacert-publish.yml' | |
permissions: | |
contents: read | |
jobs: | |
publish-ca-certificates: | |
if: github.repository == 'adoptium/installer' | |
name: "Publish ca-certificates" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./linux | |
steps: | |
- name: Checkout | |
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 | |
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 | |
with: | |
java-version: '17' | |
java-package: jdk | |
architecture: x64 | |
distribution: 'temurin' | |
- uses: jfrog/setup-jfrog-cli@d82fe26823e1f25529250895d5673f65b02af085 # v4.0.1 | |
env: | |
JF_URL: https://adoptium.jfrog.io | |
JF_USER: ${{ secrets.ARTIFACTORY_USER }} | |
JF_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
- name: Build | |
run: | | |
export _JAVA_OPTIONS="-Xmx4G" | |
./gradlew --parallel :ca-certificates:package --stacktrace | |
- name: Check if deb file exists in Artifactory | |
id: check-deb | |
run: | | |
FILE=$(ls ca-certificates/debian/build/ospackage/*.deb) | |
echo "File to upload: ${FILE}" | |
FILE_EXISTS=$(jf rt s --count=true "deb/pool/main/a/adoptium-ca-certificates/$(basename $FILE)") | |
if [[ "$FILE_EXISTS" == "0" ]]; then | |
echo file_exists=false >> "$GITHUB_OUTPUT" | |
fi | |
- name: Upload deb file to Artifactory | |
if: steps.check-deb.outputs.file_exists == 'false' | |
run: | | |
debVersionList=("trixie" "bookworm" "bullseye" "buster" "noble" "jammy" "focal" "bionic") | |
for debVersion in "${debVersionList[@]}"; do | |
distroList+="deb.distribution=${debVersion};" | |
done | |
FILE=$(ls ca-certificates/debian/build/ospackage/*.deb) | |
jf rt u "$FILE" "deb/pool/main/a/adoptium-ca-certificates/$(basename ${FILE});deb.architecture=all;deb.component=main;${distroList}" --flat=true |