Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishing artifacts #1541

Merged
merged 2 commits into from Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitattributes
@@ -0,0 +1,5 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Declare files that will always have LF line endings on checkout.
**/publishPackages text eol=lf
23 changes: 23 additions & 0 deletions .github/actions/publish-deb/action.yaml
@@ -0,0 +1,23 @@
name: "Publish Debian Packages"
description: >
Publish debian packages to artifactory using the jfrog cli.
This action wraps a script that performs organized publishing of debian packages.

inputs:
sourceDirectory:
description: "The directory containing the packages to be published."
required: true
distribution:
description: "The distribution supported by the package. i.e xenial, focal, etc."
required: true
component:
description: "The component type. i.e. stable, rc, dev, etc."
required: true

runs:
using: "composite"
steps:
- name: Publish
shell: bash
run: |
${{ github.action_path }}/publishPackages "${{ inputs.sourceDirectory }}" "${{ inputs.distribution }}" "${{ inputs.component }}"
33 changes: 33 additions & 0 deletions .github/actions/publish-deb/publishPackages
@@ -0,0 +1,33 @@
#!/bin/bash
SCRIPT_HOME="$( cd "$( dirname "$0" )" && pwd )"

sourceDirectory=${1}
distribution=${2}
component=${3}
uploadSpec=${UPLOAD_SPEC:-${4:-"${SCRIPT_HOME}/upload-spec.json"}}

export CI=true

fileList=$(find "${sourceDirectory}" -type f -name '*.deb' -mindepth 1 -maxdepth 1 -printf "%f\n" 2>/dev/null)
for name in ${fileList}; do
shortName=$(echo "${name}" | sed -rn 's~^(python3-)?([^.]*)_.*.deb~\2~p')
architecture=$(echo "${name}" | sed -rn 's~^.*_(.*).deb~\1~p')
startingLetter=$(echo "${shortName}" | sed -rn 's~^(.).*~\1~p')

echo "====================================================================================================================="
echo "name: ${name}"
echo "shortName: ${shortName}"
echo "architecture: ${architecture}"
echo "startingLetter: ${startingLetter}"
echo "distribution: ${distribution}"
echo "component: ${component}"
echo "uploadSpec: ${uploadSpec}"
echo "---------------------------------------------------------------------------------------------------------------------"
jfrog rt u \
--deb ${distribution}/${component}/${architecture} \
--spec ${uploadSpec}\
--spec-vars "SOURCE_DIR=${sourceDirectory};PACKAGE_NAME=${name};COMPONENT=${component};PACKAGE_STARTING_LETTER=${startingLetter};PACKAGE_SHORT_NAME=${shortName}" \
--detailed-summary
echo "====================================================================================================================="
echo
done
8 changes: 8 additions & 0 deletions .github/actions/publish-deb/upload-spec.json
@@ -0,0 +1,8 @@
{
"files": [
{
"pattern": "${SOURCE_DIR}/${PACKAGE_NAME}",
"target": "indy/pool/${COMPONENT}/${PACKAGE_STARTING_LETTER}/${PACKAGE_SHORT_NAME}/"
}
]
}
63 changes: 63 additions & 0 deletions .github/actions/set-version/action.yaml
@@ -0,0 +1,63 @@
name: "Set Version"
description: "Sets version parameters and makes them available as outputs for subsequent processes."

inputs:
moduleName:
description: "The name of the module containing the version management APIs for the project; i.e. load_version and set_version"
required: true
default: "plenum"
isDev:
description: "A flag indicating whether or not this is a dev build; set to either 'true' or 'false'."
required: true
default: false
isRC:
description: "A flag indicating whether or not this is a release candidate build; set to either 'true' or 'false'."
required: true
default: false

outputs:
targetReleaseVer:
description: "The target release version."
value: ${{ steps.versions.outputs.targetReleaseVer }}
upstreamVer:
description: "The version number to use with Python packages."
value: ${{ steps.versions.outputs.upstreamVer }}
pkgVer:
description: "The version number to use with Debian packages."
value: ${{ steps.versions.outputs.pkgVer }}

runs:
using: "composite"
steps:
- name: Set Versions
id: versions
shell: bash
run: |
fullVersion=$(python3 -c "from ${{ inputs.moduleName }} import load_version; print(load_version().full)")
release=$(python3 -c "from ${{ inputs.moduleName }} import load_version; print(load_version().release)")
pre=$(python3 -c "from ${{ inputs.moduleName }} import load_version; pre = load_version().parts[-2]; print('' if pre is None else pre)")
revision=$(python3 -c "from ${{ inputs.moduleName }} import load_version; rev = load_version().parts[-1]; print('' if rev is None else rev)")

targetReleaseVer=${release}
upstreamVer=${targetReleaseVer}
pkgVer=${upstreamVer}

if [ ${{ inputs.isDev }} == "true" ] || [ ${{ inputs.isRC }} == "true" ]; then
if [ ${{ inputs.isDev }} == "true" ]; then
rev=${{ github.run_number }}
else
rev=${revision}
fi

upstreamVer+=".${pre}${rev}"
pkgVer+="~${pre}${rev}"
fi

# Set Outputs ...
echo "::set-output name=targetReleaseVer::${targetReleaseVer}"
echo "::set-output name=upstreamVer::${upstreamVer}"
echo "::set-output name=pkgVer::${pkgVer}"

echo "Target Release version: ${targetReleaseVer}"
echo "PyPI Release version: ${upstreamVer}"
echo "Debian Release version: ${pkgVer}"