Skip to content

Commit

Permalink
Merge pull request #1680 from WadeBarnes/publishing-artifacts
Browse files Browse the repository at this point in the history
Add support for publishing Debian packages
  • Loading branch information
WadeBarnes authored Aug 10, 2021
2 parents 04ca664 + 0730c69 commit ccbd47d
Show file tree
Hide file tree
Showing 14 changed files with 489 additions and 73 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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: "indy_node"
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}"
28 changes: 16 additions & 12 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
### Github Actions Workflow
# GitHub Actions Workflow

This build file replaces the existing `Jenkins.ci` build process.
The workflow in the [build.yaml](build.yaml) file replaces the existing [Jenkins.ci](../../Jenkinsfile.ci) build process.

`lint.yaml` replaces the `Static code validation` stage of the Jenkins build.
The `lint` job replaces the `Static code validation` stage of the Jenkins pipeline, while the remainder of the jobs replace the `Build / Test` stage.

`build.yaml` replaces the `Build / Test` stage of the Jenkins build.
The `Build result notification` stage was not moved to GHA, as build failures will be reports via GHA.

Many of the other stages are replaced merely by the fact we're using Github Actions, we use prebuild Docker containers so we don't have to replicate the steps for building containers.

The `Build result notification` stage was not moved to GHA, build failures will be reports via GHA.

The build process for `Jenkins.nightly` was not ported to GHA.

#### Configuring actions
Support for Windows continues as a `ToDo` item.


## Configuring actions

If you are cloning or forking this repo you will need to configure two secrets for Actions to run correctly.

Secrets can be set via Settings -> Secrets -> New repository secret.
Secrets can be set via Settings -> Secrets -> New repository secret:

`CR_USER`: is your GH username. It must be lowercase.
`CR_PAT`: can be created by following the [Creating a personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) documentation.

When you create your token, the only permission you need to select is `write:packages` **Upload packages to GitHub package registry**, all other necessary permissions will be selected by default.

CR_USER is your GH username.
CR_PAT can be created by following [these directions](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
You may also need to enable [Improved container support](https://docs.github.com/en/packages/guides/enabling-improved-container-support) in order to allow the images to be written to your repository. You'll see an error to this affect if this is the case.

Once you have run the build once with those secrets, you have to make then package public.
Access the package at https://ghcr.io/USER/indy-node/indy-node-build or https://ghcr.io/USER/indy-node/indy-node-lint then change the visibility in 'Package Settings' to 'Public' then re-run the build.
Once you have run the build once with those secrets, you have to make the images public. Access the packages at https://ghcr.io/USER/indy-node/node-build and https://ghcr.io/USER/indy-node/node-lint and change the visibility in 'Package Settings' to 'Public' then re-run the build. Alternatively, if you would prefer to keep the images private, you can manage access to the package and select only the user account associated with the token you setup above.
Loading

0 comments on commit ccbd47d

Please sign in to comment.