-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
427 additions
and
11 deletions.
There are no files selected for viewing
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,119 @@ | ||
name: package | ||
description: Package module using nfpm | ||
inputs: | ||
nfpm_file_pattern: | ||
description: The pattern of the nfpm configuration file(s) | ||
required: true | ||
package_extension: | ||
description: The package extension (deb or rpm) | ||
required: true | ||
distrib: | ||
description: The package distrib | ||
required: true | ||
major_version: | ||
description: The major version | ||
required: false | ||
minor_version: | ||
description: The minor version | ||
required: false | ||
release: | ||
description: The package release number | ||
required: false | ||
arch: | ||
description: The package architecture | ||
required: false | ||
commit_hash: | ||
description: The commit hash | ||
required: true | ||
cache_key: | ||
description: The package files cache key | ||
required: true | ||
rpm_gpg_key: | ||
description: The rpm gpg key | ||
required: true | ||
rpm_gpg_signing_key_id: | ||
description: The rpm gpg signing key identifier | ||
required: true | ||
rpm_gpg_signing_passphrase: | ||
description: The rpm gpg signing passphrase | ||
required: true | ||
stability: | ||
description: "branch stability (stable, testing, unstable, canary)" | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Import gpg key | ||
env: | ||
RPM_GPG_SIGNING_KEY: ${{ inputs.rpm_gpg_key }} | ||
run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg | ||
shell: bash | ||
|
||
- name: Build ${{ inputs.package_extension }} files | ||
env: | ||
RPM_GPG_SIGNING_KEY_ID: ${{ inputs.rpm_gpg_signing_key_id }} | ||
RPM_GPG_SIGNING_PASSPHRASE: ${{ inputs.rpm_gpg_signing_passphrase }} | ||
run: | | ||
export MAJOR_VERSION="${{ inputs.major_version }}" | ||
export VERSION="${{ inputs.major_version }}.${{ inputs.minor_version }}" | ||
export RELEASE="${{ inputs.release }}" | ||
export ARCH="${{ inputs.arch }}" | ||
if [ "${{ inputs.package_extension }}" = "rpm" ]; then | ||
export DIST=".${{ inputs.distrib }}" | ||
else | ||
export DIST="" | ||
if [ "${{ inputs.stability }}" = "unstable" ] || [ "${{ inputs.stability }}" = "canary" ]; then | ||
export RELEASE="$RELEASE~${{ inputs.distrib }}" | ||
else | ||
export RELEASE="1~${{ inputs.distrib }}" | ||
fi | ||
fi | ||
MAJOR_LEFT=$( echo $MAJOR_VERSION | cut -d "." -f1 ) | ||
MAJOR_RIGHT=$( echo $MAJOR_VERSION | cut -d "-" -f1 | cut -d "." -f2 ) | ||
BUMP_MAJOR_RIGHT=$(( MAJOR_RIGHT_PART + 1 )) | ||
if [ "$MAJOR_RIGHT" = "04" ]; then | ||
BUMP_MAJOR_LEFT="$MAJOR_LEFT" | ||
BUMP_MAJOR_RIGHT="10" | ||
else | ||
BUMP_MAJOR_LEFT=$(( $MAJOR_LEFT + 1 )) | ||
BUMP_MAJOR_RIGHT="04" | ||
fi | ||
export NEXT_MAJOR_VERSION="$BUMP_MAJOR_LEFT.$BUMP_MAJOR_RIGHT" | ||
export RPM_SIGNING_KEY_FILE="$(pwd)/key.gpg" | ||
export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID" | ||
export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE" | ||
for FILE in ${{ inputs.nfpm_file_pattern }}; do | ||
DIRNAME=$(dirname $FILE) | ||
BASENAME=$(basename $FILE) | ||
if [ -f $DIRNAME/env/.env.${{ inputs.distrib }} ]; then | ||
source $DIRNAME/env/.env.${{ inputs.distrib }} | ||
fi | ||
cd $DIRNAME | ||
sed -i "s/@COMMIT_HASH@/${{ inputs.commit_hash }}/g" $BASENAME | ||
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }} | ||
cd - | ||
mv $DIRNAME/*.${{ inputs.package_extension }} ./ | ||
done | ||
shell: bash | ||
|
||
- name: Cache packages | ||
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 | ||
with: | ||
path: ./*.${{ inputs.package_extension }} | ||
key: ${{ inputs.cache_key }} | ||
|
||
# Update if condition to true to get packages as artifacts | ||
- if: ${{ false }} | ||
name: Upload package artifacts | ||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 | ||
with: | ||
name: ${{ inputs.arch != '' && format('packages-{0}-{1}', inputs.distrib, inputs.arch) || format('packages-{0}', inputs.distrib) }} | ||
path: ./*.${{ inputs.package_extension}} | ||
retention-days: 1 |
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
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
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
Oops, something went wrong.