1- name : Build OpenSSL 3.x
1+ name : Build OpenSSL
22run-name : Build OpenSSL ${{ inputs.version }} via ${{ github.event_name }}
33
44on :
55 workflow_dispatch :
66 inputs :
77 build_type :
8- description : ' Build Type '
8+ description : ' Build Source: OpenSSL Release or OpenSSL Branch/OpenSSL fork '
99 required : true
1010 type : choice
1111 options :
1212 - release
1313 - branch
1414 default : release
1515 version :
16- description : ' OpenSSL Version or Branch (e.g., 3.4.0 or master )'
16+ description : ' OpenSSL Release Version, OpenSSL Branch Name or OpenSSL Fork Repo (e.g. 3.4.0, master, or user/repo/branch )'
1717 required : true
1818 type : string
1919 ignore_eol :
@@ -49,20 +49,31 @@ jobs:
4949 # 0. VALIDATE VERSION & EOL
5050 # =========================================================================
5151 validate-version :
52- name : Validate ${{ inputs.build_type == 'release' && 'Version' || 'Branch' }}
52+ name : Validate Inputs
5353 runs-on : ubuntu-latest
54+ permissions :
55+ actions : write
5456 outputs :
5557 version : ${{ steps.check.outputs.version }}
58+ target_repo : ${{ steps.check.outputs.target_repo }}
5659 ref : ${{ steps.check.outputs.ref }}
60+ sha : ${{ steps.check.outputs.sha }}
5761 artifact_version : ${{ steps.check.outputs.artifact_version }}
62+ slugified_version : ${{ steps.check.outputs.slugified_version }}
63+ is_fork : ${{ steps.check.outputs.is_fork }}
5864 steps :
5965 - name : Check EOL or Branch Existence
6066 id : check
67+ env :
68+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6169 run : |
6270 VERSION="${{ inputs.version }}"
6371 BUILD_TYPE="${{ inputs.build_type }}"
6472 IGNORE_EOL="${{ inputs.ignore_eol }}"
6573
74+ TARGET_REPO="openssl/openssl"
75+ IS_FORK="false"
76+
6677 if [ "$BUILD_TYPE" == "release" ]; then
6778 MAJOR_MINOR=$(echo "$VERSION" | cut -d. -f1,2)
6879 EOL_DATE=$(curl -s https://endoflife.date/api/openssl.json | jq -r ".[] | select(.cycle == \"$MAJOR_MINOR\") | .eol")
@@ -80,20 +91,56 @@ jobs:
8091 echo "⚠️ Ignore EOL is checked. Proceeding anyway."
8192 fi
8293 fi
83- echo "ref=openssl-$VERSION" >> $GITHUB_OUTPUT
84- echo "artifact_version=$VERSION" >> $GITHUB_OUTPUT
94+ TARGET_REF="openssl-$VERSION"
95+
96+ echo "🔍 Resolving SHA for tag '$TARGET_REF'..."
97+ SHA=$(git ls-remote --tags https://github.com/$TARGET_REPO.git "$TARGET_REF" | awk '{print $1}')
98+ if [ -z "$SHA" ]; then
99+ echo "❌ Tag '$TARGET_REF' not found in $TARGET_REPO."
100+ exit 1
101+ fi
102+
103+ ARTIFACT_VERSION="$VERSION"
104+ SLUGIFIED_VERSION="$VERSION"
85105 else
86106 # Branch Mode
87- echo "🔍 Verifying branch '$VERSION' in upstream repository..."
88- if ! git ls-remote --heads https://github.com/openssl/openssl.git "$VERSION" | grep -q "$VERSION"; then
89- echo "❌ Branch '$VERSION' does not exist in openssl/openssl repository."
90- exit 1
107+ if [[ "$VERSION" == */*/* ]]; then
108+ # Format: user/repo/branch
109+ TARGET_REPO=$(echo "$VERSION" | cut -d'/' -f1,2)
110+ TARGET_REF=$(echo "$VERSION" | cut -d'/' -f3-)
111+ IS_FORK="true"
112+ else
113+ TARGET_REF="$VERSION"
91114 fi
115+
116+ echo "🔍 Resolving SHA for branch/ref '$TARGET_REF' in repository '$TARGET_REPO'..."
117+ SHA=$(git ls-remote https://github.com/$TARGET_REPO.git "$TARGET_REF" | awk '{print $1}')
118+
119+ if [ -z "$SHA" ]; then
120+ # Check if it's already a SHA
121+ if [[ "$TARGET_REF" =~ ^[0-9a-f]{40}$ ]]; then
122+ SHA="$TARGET_REF"
123+ else
124+ echo "❌ Reference '$TARGET_REF' does not exist in $TARGET_REPO."
125+ exit 1
126+ fi
127+ fi
128+
92129 TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ)
93- echo "ref=$VERSION" >> $GITHUB_OUTPUT
94- echo "artifact_version=${VERSION}_${TIMESTAMP}" >> $GITHUB_OUTPUT
130+ # Slugify the whole version input (e.g. user/repo/branch -> user_repo_branch)
131+ SLUGIFIED_VERSION=$(echo "$VERSION" | sed 's/\//_/g')
132+ # Truncate for filename safety
133+ SAFE_PART=$(echo "$SLUGIFIED_VERSION" | cut -c 1-100)
134+ ARTIFACT_VERSION="${SAFE_PART}_${TIMESTAMP}"
95135 fi
96136
137+ # Output resolved information
138+ echo "target_repo=$TARGET_REPO" >> $GITHUB_OUTPUT
139+ echo "is_fork=$IS_FORK" >> $GITHUB_OUTPUT
140+ echo "ref=$TARGET_REF" >> $GITHUB_OUTPUT
141+ echo "sha=$SHA" >> $GITHUB_OUTPUT
142+ echo "artifact_version=$ARTIFACT_VERSION" >> $GITHUB_OUTPUT
143+ echo "slugified_version=$SLUGIFIED_VERSION" >> $GITHUB_OUTPUT
97144 echo "version=$VERSION" >> $GITHUB_OUTPUT
98145
99146 # =========================================================================
@@ -106,8 +153,8 @@ jobs:
106153 steps :
107154 - uses : actions/checkout@v6
108155 with :
109- repository : openssl/openssl
110- ref : ${{ needs.validate-version.outputs.ref }}
156+ repository : ${{ needs.validate-version.outputs.target_repo }}
157+ ref : ${{ needs.validate-version.outputs.sha }}
111158
112159 - name : Build Common Assets
113160 run : |
@@ -149,7 +196,7 @@ jobs:
149196 -----------------------------------------------
150197 Windows file systems fail to extract Unix symbolic links. To ensure cross-platform compatibility, this archive contains only the physical shared library files.
151198
152- If this package includes the 'install_symlinks.sh' script, you MUST run it from the root of the extracted directory to recreate the required library symlinks (e.g., libcrypto.so -> libcrypto.so.3 ).
199+ If this package includes the 'install_symlinks.sh' script, you MUST run it from the root of the extracted directory to recreate the required library symlinks (e.g., libcrypto.so -> libcrypto.so.X ).
153200
154201 $ cd <extracted_directory>
155202 $ sh ./install_symlinks.sh
@@ -202,8 +249,8 @@ jobs:
202249 steps :
203250 - uses : actions/checkout@v6
204251 with :
205- repository : openssl/openssl
206- ref : ${{ needs.validate-version.outputs.ref }}
252+ repository : ${{ needs.validate-version.outputs.target_repo }}
253+ ref : ${{ needs.validate-version.outputs.sha }}
207254
208255 - name : Compile Windows (Standard)
209256 if : matrix.platform.label == 'Windows' && matrix.platform.arch != 'arm64ec'
@@ -260,8 +307,8 @@ jobs:
260307 mkdir raw_artifact\dist\lib\import
261308 copy "%PREFIX%\bin\openssl.exe" raw_artifact\dist\
262309 copy "%PREFIX%\bin\*.dll" raw_artifact\dist\
263- copy "%PREFIX%\lib\engines-3 \*.dll" raw_artifact\dist\engines\
264- copy "%PREFIX%\lib\ossl-modules\*.dll" raw_artifact\dist\providers\
310+ for /d %%d in ( "%PREFIX%\lib\engines-*") do copy "%%d \*.dll" raw_artifact\dist\engines\
311+ for /d %%d in ( "%PREFIX%\lib\ossl-modules*") do copy "%%d \*.dll" raw_artifact\dist\providers\
265312 copy "%PREFIX%\lib\*.lib" raw_artifact\dist\lib\import\
266313 ) else (
267314 mkdir raw_artifact\dist\lib\static
@@ -340,16 +387,18 @@ jobs:
340387 if [ "$LABEL" == "Android" ]; then
341388 find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "*.so" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
342389 else
343- # Versioned libs only
344- find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "*.so.3" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
345- find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "*.3.dylib" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
390+ # Versioned libs only: libcrypto.so.X, libssl.so.X or libcrypto.X.dylib, libssl.X.dylib
391+ find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "libcrypto.so.*" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
392+ find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "libssl.so.*" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
393+ find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "libcrypto.*.dylib" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
394+ find "$PREFIX/lib" "$PREFIX/lib64" -maxdepth 1 -type f -name "libssl.*.dylib" -exec cp {} raw_artifact/dist/ \; 2>/dev/null || true
346395 fi
347396
348397 # Engines & Providers
349- find "$PREFIX" -path "*/engines-3 /*.so" -exec cp {} raw_artifact/dist/engines/ \; 2>/dev/null || true
350- find "$PREFIX" -path "*/engines-3 /*.dylib" -exec cp {} raw_artifact/dist/engines/ \; 2>/dev/null || true
351- find "$PREFIX" -path "*/ossl-modules/*.so" -exec cp {} raw_artifact/dist/providers/ \; 2>/dev/null || true
352- find "$PREFIX" -path "*/ossl-modules/*.dylib" -exec cp {} raw_artifact/dist/providers/ \; 2>/dev/null || true
398+ find "$PREFIX" -path "*/engines-* /*.so" -exec cp {} raw_artifact/dist/engines/ \; 2>/dev/null || true
399+ find "$PREFIX" -path "*/engines-* /*.dylib" -exec cp {} raw_artifact/dist/engines/ \; 2>/dev/null || true
400+ find "$PREFIX" -path "*/ossl-modules* /*.so" -exec cp {} raw_artifact/dist/providers/ \; 2>/dev/null || true
401+ find "$PREFIX" -path "*/ossl-modules* /*.dylib" -exec cp {} raw_artifact/dist/providers/ \; 2>/dev/null || true
353402
354403 # Stripping (Non-macOS)
355404 if [ "$LABEL" != "macOS" ]; then
@@ -358,12 +407,26 @@ jobs:
358407 fi
359408
360409 # Symlinks script (Linux/macOS)
361- if [ "$LABEL" == "Linux" ]; then
362- echo -e "#!/bin/sh\necho \"Restoring shared library symlinks...\"\nln -sf libcrypto.so.3 libcrypto.so\nln -sf libssl.so.3 libssl.so" > raw_artifact/dist/install_symlinks.sh
363- chmod +x raw_artifact/dist/install_symlinks.sh
364- elif [ "$LABEL" == "macOS" ]; then
365- echo -e "#!/bin/sh\necho \"Restoring shared library symlinks...\"\nln -sf libcrypto.3.dylib libcrypto.dylib\nln -sf libssl.3.dylib libssl.dylib" > raw_artifact/dist/install_symlinks.sh
366- chmod +x raw_artifact/dist/install_symlinks.sh
410+ if [ "$LABEL" == "Linux" ] || [ "$LABEL" == "macOS" ]; then
411+ echo "#!/bin/sh" > raw_artifact/dist/install_symlinks.sh
412+ echo "echo \"Restoring shared library symlinks...\"" >> raw_artifact/dist/install_symlinks.sh
413+
414+ cd raw_artifact/dist
415+ for lib in libcrypto libssl; do
416+ if [ "$LABEL" == "Linux" ]; then
417+ REAL_FILE=$(ls ${lib}.so.* 2>/dev/null | head -n 1)
418+ if [ -n "$REAL_FILE" ]; then
419+ echo "ln -sf $REAL_FILE ${lib}.so" >> install_symlinks.sh
420+ fi
421+ else
422+ REAL_FILE=$(ls ${lib}.*.dylib 2>/dev/null | head -n 1)
423+ if [ -n "$REAL_FILE" ]; then
424+ echo "ln -sf $REAL_FILE ${lib}.dylib" >> install_symlinks.sh
425+ fi
426+ fi
427+ done
428+ chmod +x install_symlinks.sh
429+ cd - > /dev/null
367430 fi
368431
369432 else
@@ -556,19 +619,33 @@ jobs:
556619
557620 # Create Metadata
558621 if [ "${{ inputs.build_type }}" == "branch" ]; then
559- echo "branch: ${{ needs.validate-version.outputs.version }}" > dist/version.txt
622+ echo "branch: ${{ needs.validate-version.outputs.slugified_version }}" > dist/version.txt
560623 else
561- echo "${{ needs.validate-version.outputs.version }}" > dist/version.txt
624+ echo "${{ needs.validate-version.outputs.slugified_version }}" > dist/version.txt
562625 fi
563626
564627 # Create Symlink Script (POSIX only, if not already present)
565628 if [ ! -f dist/install_symlinks.sh ]; then
566- if [ "${{ matrix.label }}" == "Linux" ]; then
567- echo -e "#!/bin/sh\necho \"Restoring shared library symlinks...\"\nln -sf libcrypto.so.3 libcrypto.so\nln -sf libssl.so.3 libssl.so" > dist/install_symlinks.sh
568- chmod +x dist/install_symlinks.sh
569- elif [ "${{ matrix.label }}" == "macOS" ]; then
570- echo -e "#!/bin/sh\necho \"Restoring shared library symlinks...\"\nln -sf libcrypto.3.dylib libcrypto.dylib\nln -sf libssl.3.dylib libssl.dylib" > dist/install_symlinks.sh
571- chmod +x dist/install_symlinks.sh
629+ if [ "${{ matrix.label }}" == "Linux" ] || [ "${{ matrix.label }}" == "macOS" ]; then
630+ echo "#!/bin/sh" > dist/install_symlinks.sh
631+ echo "echo \"Restoring shared library symlinks...\"" >> dist/install_symlinks.sh
632+
633+ cd dist
634+ for lib in libcrypto libssl; do
635+ if [ "${{ matrix.label }}" == "Linux" ]; then
636+ REAL_FILE=$(ls ${lib}.so.* 2>/dev/null | head -n 1)
637+ if [ -n "$REAL_FILE" ]; then
638+ echo "ln -sf $REAL_FILE ${lib}.so" >> install_symlinks.sh
639+ fi
640+ else
641+ REAL_FILE=$(ls ${lib}.*.dylib 2>/dev/null | head -n 1)
642+ if [ -n "$REAL_FILE" ]; then
643+ echo "ln -sf $REAL_FILE ${lib}.dylib" >> install_symlinks.sh
644+ fi
645+ fi
646+ done
647+ chmod +x install_symlinks.sh
648+ cd - > /dev/null
572649 fi
573650 fi
574651
@@ -590,7 +667,7 @@ jobs:
590667 retention-days : 5
591668
592669 - name : Upload Build Metadata (Once)
593- if : matrix.label == 'Linux' && matrix.arch == 'x64'
670+ if : matrix.label == 'Linux' && matrix.arch == 'x64' && needs.validate-version.outputs.is_fork == 'false'
594671 uses : actions/upload-artifact@v7
595672 with :
596673 name : build-metadata
@@ -615,7 +692,7 @@ jobs:
615692 echo "Fetching artifacts for run ${{ github.run_id }}..."
616693
617694 # Use gh api to list artifacts
618- ARTIFACTS=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/ artifacts --paginate)
695+ ARTIFACTS=$(gh api repos/${{ github.repository }}/actions/artifacts --paginate)
619696
620697 # Filter for IDs of artifacts that start with 'raw-' or are 'openssl-common-assets'
621698 IDS=$(echo "$ARTIFACTS" | jq -r '.artifacts[] | select (.name | startswith("raw-") or . == "openssl-common-assets") | .id')
0 commit comments