-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
454 additions
and
388 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
name: "package-delivery" | ||
description: "Deliver packages" | ||
inputs: | ||
module_name: | ||
description: "The package module name" | ||
required: true | ||
distrib: | ||
description: "The distribution used for packaging" | ||
required: true | ||
cache_key: | ||
description: "The cached package key" | ||
required: true | ||
stability: | ||
description: "The package stability (stable, testing, unstable)" | ||
required: true | ||
release_type: | ||
description: "Type of release (hotfix, release)" | ||
required: true | ||
artifactory_token: | ||
description: "token for artifactory" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Validate inputs | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
if ('${{ inputs.module_name }}' === '') { | ||
throw new Error('module_name input must be defined'); | ||
} | ||
if (! ['stable', 'testing', 'unstable'].includes('${{ inputs.stability }}')) { | ||
throw new Error(`Stability ${{ inputs.stability }} should not deliver packages`); | ||
} | ||
if ('${{ inputs.stability }}' === 'testing' && ! ['testing', 'hotfix'].includes('${{ inputs.release_type }}')) { | ||
throw new Error('release_type input must be defined when stability is testing'); | ||
} | ||
- name: Parse distrib name | ||
id: parse-distrib | ||
uses: ./.github/actions/parse-distrib | ||
with: | ||
distrib: ${{ inputs.distrib }} | ||
|
||
- name: Get repository stability path | ||
id: get_repository_stability_path | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
let stabilitySubdirectory = '${{ inputs.stability }}'; | ||
if ('${{ inputs.stability }}' === 'testing' && '${{ inputs.release_type }}' === 'hotfix') { | ||
stabilitySubdirectory = '${{ inputs.stability }}-${{ inputs.release_type }}'; | ||
} | ||
let repositoryStabilityPath = ''; | ||
if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'el') { | ||
repositoryStabilityPath = `rpm-connectors/2e83f5ff110c44a9cab8f8c7ebbe3c4f/${{ inputs.distrib }}/${stabilitySubdirectory}`; | ||
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'ubuntu') { | ||
repositoryStabilityPath = `ubuntu-connectors-${{ inputs.stability }}`; | ||
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'debian') { | ||
repositoryStabilityPath = `apt-connectors-${{ inputs.stability }}`; | ||
} else { | ||
throw new Error(`Repository cannot be find for distribution: ${{ inputs.distrib }}`); | ||
} | ||
core.setOutput( | ||
'repository_stability_path', | ||
repositoryStabilityPath, | ||
); | ||
- if: ${{ inputs.stability != 'stable' }} | ||
name: Restore packages from cache | ||
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | ||
with: | ||
path: ./*.${{ steps.parse-distrib.outputs.package_extension }} | ||
key: ${{ inputs.cache_key }} | ||
fail-on-cache-miss: true | ||
|
||
- uses: jfrog/setup-jfrog-cli@9fe0f98bd45b19e6e931d457f4e98f8f84461fb5 # v4.4.1 | ||
with: | ||
disable-job-summary: true | ||
disable-auto-build-publish: true | ||
env: | ||
JF_URL: https://centreon.jfrog.io | ||
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }} | ||
|
||
- if: ${{ inputs.stability == 'testing' }} | ||
name: Clean existing testing packages | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'el') { | ||
await exec.exec( | ||
`jf rt del "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/*/${{ inputs.module_name }}/*.rpm" --exclusions "*/RPMS/*" --quiet` | ||
); | ||
} else if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'deb') { | ||
await exec.exec( | ||
`jf rt del "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/pool/${{ inputs.module_name }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb" --quiet --props "release_type=${{ inputs.release_type }}"` | ||
); | ||
} | ||
- name: Download packages from testing | ||
if: ${{ inputs.stability == 'testing' }} | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
const warningNoPromote = 'No packages are promoted because push is not related to a hotfix/release pull request.'; | ||
const commitSha = context.sha; | ||
const { data: { items } } = await github.rest.search.issuesAndPullRequests({ | ||
q: `${commitSha} type:pr is:merged` | ||
}); | ||
if (items.length === 0) { | ||
core.warning(warningNoPromote); | ||
return; | ||
} | ||
const prNumber = items[0].number; | ||
const pr = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: prNumber | ||
}); | ||
const prBaseRef = pr.data?.base?.ref || 'unknown'; | ||
let releaseType = ''; | ||
switch (true) { | ||
case /^release.+/.test(prBaseRef): | ||
releaseType = 'release'; | ||
break; | ||
case /^hotfix.+/.test(prBaseRef): | ||
releaseType = 'hotfix'; | ||
break; | ||
default: | ||
core.warning(warningNoPromote); | ||
return; | ||
} | ||
let fromStabilitySubdirectory = 'testing'; | ||
if (releaseType === 'hotfix' ) { | ||
fromStabilitySubdirectory = `testing-${releaseType}`; | ||
} | ||
if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'el') { | ||
await exec.exec( | ||
`jf rt download --flat "rpm-connectors/2e83f5ff110c44a9cab8f8c7ebbe3c4f/${{ inputs.distrib }}/${fromStabilitySubdirectory}/*/${{ inputs.module_name }}/*.rpm"` | ||
); | ||
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'ubuntu') { | ||
await exec.exec( | ||
`jf rt download --flat "ubuntu-connectors-testing/pool/${{ inputs.module_name }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb" --props "release_type=${{ inputs.release_type }}"` | ||
); | ||
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'debian') { | ||
await exec.exec( | ||
`jf rt download --flat "apt-connectors-testing/pool/${{ inputs.module_name }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb" --props "release_type=${{ inputs.release_type }}"` | ||
); | ||
} | ||
- name: Publish packages to ${{ inputs.stability }} | ||
if: | | ||
contains(fromJson('["testing", "unstable"]'), inputs.stability) || | ||
(needs.get-version.outputs.stability == 'stable' && github.event_name == 'push') | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: | | ||
const path = require('path'); | ||
const globber = await glob.create('*.${{ steps.parse-distrib.outputs.package_extension }}'); | ||
const debTargetProps = '${{ inputs.stability }}' == 'testing' ? '--target-props "release_type=${{ inputs.release_type }}"' : ''; | ||
for await (const file of globber.globGenerator()) { | ||
const fileName = path.basename(file); | ||
if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'rpm') { | ||
let arch = 'noarch'; | ||
if (/x86_64/.test(fileName)) { | ||
arch = 'x86_64'; | ||
} | ||
await exec.exec( | ||
`jf rt upload --flat "*.rpm" "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/${arch}/${{ inputs.module_name }}/*.rpm"` | ||
); | ||
} else if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'deb') { | ||
let arch = 'all'; | ||
const matches = fileName.match(/_([^_]+)\.deb/); | ||
if (matches !== null && matches.length > 1) { | ||
arch = matches[1]; | ||
} | ||
await exec.exec( | ||
`jf rt upload --flat "*.deb" "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/${arch}" ${debTargetProps}` | ||
); | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
19 changes: 0 additions & 19 deletions
19
.github/docker/packaging/Dockerfile.packaging-plugins-centos7
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.