Clean up onedir archives

This commit is contained in:
Twangboy 2023-01-12 13:03:35 -07:00 committed by Megan Wilhite
parent 76a1b2c3bc
commit 841ca5da91
5 changed files with 89 additions and 23 deletions

View file

@ -1,6 +1,6 @@
---
name: build-linux-onedir
description: Build Linux Onedir Package
name: build-onedir-deps
description: Build Onedir Dependencies
inputs:
platform:
required: true

View file

@ -1,6 +1,6 @@
---
name: build-linux-onedir
description: Build Linux Onedir Package
name: build-onedir-pkg
description: Build Onedir Package
inputs:
platform:
required: true
@ -29,6 +29,7 @@ runs:
key: ${{ env.CACHE_SEED }}|relenv|${{ env.RELENV_VERSION }}|deps|${{ inputs.platform }}|${{ inputs.arch }}|${{ inputs.package-name }}|${{ hashFiles(format('{0}/.relenv/**/*.xz', github.workspace), 'requirements/static/pkg/*/*.txt') }}
- name: Install Salt Into Onedir
if: "${{ inputs.platform }}" != "windows"
env:
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
@ -36,26 +37,63 @@ runs:
RELENV_PIP_DIR: "1"
shell: bash
run: |
if [ "${{ inputs.platform }}" != "windows" ]; then
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install .
else
artifacts/${{ inputs.package-name }}/Scripts/python -m pip install .
artifacts/${{ inputs.package-name }}/bin/python3 -m pip install .
if [ "${{ inputs.platform }}" == "darwin" ]; then
pkg/macos/prep_salt.sh --build-dir artifacts/${{ inputs.package-name }}
rm -rf artifacts/${{ inputs.package-name }}/opt
rm -rf artifacts/${{ inputs.package-name }}/etc
rm -rf artifacts/${{ inputs.package-name }}/Library
fi
- name: Install Salt Into Onedir (Windows)
if: "${{ inputs.platform }}" == "windows"
env:
PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/
PIP_EXTRA_INDEX_URL: https://pypi.org/simple
USE_STATIC_REQUIREMENTS: "1"
shell: powershell
run: |
# install salt
pkg\windows\install_salt.cmd -BuildDir "artifacts\${{ inputs.package-name }}" -CICD
# prep salt
pkg\windows\prep_salt.cmd -BuildDir "artifacts\${{ inputs.package-name }}" -CICD
# Remove package specific items
Remove-Item -Path artifacts\${{ inputs.package-name }}\configs -Recurse
- name: Cleanup Salt Onedir Directory
shell: bash
run: |
tools pkg pre-archive-cleanup artifacts/${{ inputs.package-name }}
- name: Create Tarball
- name: Create Archive
if: "${{ inputs.platform }}" != "windows"
shell: bash
run: |
cd artifacts/
tar -cJf ${{ inputs.package-name }}-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz ${{ inputs.package-name }}
- name: Create Archive (Windows)
if: "${{ inputs.platform }}" == "windows"
env:
ProgressPreference: "SilentlyContinue"
ErrorActionPreference: "Stop"
shell: powershell
run: |
cd artifacts
Compress-Archive -LiteralPath ${{ inputs.package-name }}" -DestinationPath ${{ inputs.package-name }}-${{ inputs.arch }}-${{ inputs.platform }}.zip
- name: Upload Onedir Tarball as an Artifact
if: "${{ inputs.platform }}" != "windows"
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.package-name }}-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
path: artifacts/${{ inputs.package-name }}-${{ inputs.platform }}-${{ inputs.arch }}.tar.xz
retention-days: 7
- name: Upload Onedir Zipfile as an Artifact
if: "${{ inputs.platform }}" == "windows"
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.package-name }}-${{ inputs.arch }}-${{ inputs.platform }}.zip
path: artifacts/${{ inputs.package-name }}-${{ inputs.arch }}-${{ inputs.platform }}.zip
retention-days: 7

View file

@ -20,18 +20,11 @@
# ./prep_salt.sh
#
################################################################################
#-------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------
SRC_DIR="$(git rev-parse --show-toplevel)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/build"
CONF_DIR="$BUILD_DIR/etc/salt"
CMD_OUTPUT=$(mktemp -t cmd.log)
#-------------------------------------------------------------------------------
# Functions
# Script Functions
#-------------------------------------------------------------------------------
# _usage
#
# Prints out help text
@ -42,7 +35,8 @@ _usage() {
echo "usage: ${0}"
echo " [-h|--help]"
echo ""
echo " -h, --help this message"
echo " -h, --help this message"
echo " -b, --build-dir the location of the build directory"
echo ""
echo " To build the Salt package:"
echo " example: $0"
@ -83,7 +77,12 @@ while true; do
_usage
exit 0
;;
-*)
-b | --build-dir )
shift
BUILD_DIR="$*"
shift
;;
-* )
echo "Invalid Option: $1"
echo ""
_usage
@ -95,6 +94,17 @@ while true; do
esac
done
#-------------------------------------------------------------------------------
# Script Variables
#-------------------------------------------------------------------------------
SRC_DIR="$(git rev-parse --show-toplevel)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -z "$BUILD_DIR" ]; then
BUILD_DIR="$SCRIPT_DIR/build"
fi
CONF_DIR="$BUILD_DIR/etc/salt"
CMD_OUTPUT=$(mktemp -t cmd.log)
#-------------------------------------------------------------------------------
# Delete temporary files on exit
#-------------------------------------------------------------------------------

View file

@ -14,6 +14,11 @@ install_salt.ps1
#>
param(
[Parameter(Mandatory=$false)]
[Alias("b")]
# Don't pretify the output of the Write-Result
[String] $BuildDir,
[Parameter(Mandatory=$false)]
[Alias("c")]
# Don't pretify the output of the Write-Result
@ -47,7 +52,11 @@ function Write-Result($result, $ForegroundColor="Green") {
# Python Variables
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
if ( $BuildDir ) {
$BUILD_DIR = $BuildDir
} else {
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
}
$SITE_PKGS_DIR = "$BUILD_DIR\Lib\site-packages"
$SCRIPTS_DIR = "$BUILD_DIR\Scripts"
$PYTHON_BIN = "$SCRIPTS_DIR\python.exe"

View file

@ -15,6 +15,11 @@ prep_salt.ps1
#>
param(
[Parameter(Mandatory=$false)]
[Alias("b")]
# Don't pretify the output of the Write-Result
[String] $BuildDir,
[Parameter(Mandatory=$false)]
[Alias("c")]
# Don't pretify the output of the Write-Result
@ -48,7 +53,11 @@ function Write-Result($result, $ForegroundColor="Green") {
$PROJECT_DIR = $(git rev-parse --show-toplevel)
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
if ( $BuildDir ) {
$BUILD_DIR = $BuildDir
} else {
$BUILD_DIR = "$SCRIPT_DIR\buildenv"
}
$PREREQ_DIR = "$SCRIPT_DIR\prereqs"
$SCRIPTS_DIR = "$BUILD_DIR\Scripts"
$BUILD_CONF_DIR = "$BUILD_DIR\configs"
@ -138,7 +147,7 @@ if ( Test-Path -Path "$BUILD_CONF_DIR\minion" ) {
exit 1
}
Write-Host "Copying SSM to Bin: " -NoNewline
Write-Host "Copying SSM to Root: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/ssm-2.24-103-gdee49fc.exe" -OutFile "$BUILD_DIR\ssm.exe"
if ( Test-Path -Path "$BUILD_DIR\ssm.exe" ) {
Write-Result "Success" -ForegroundColor Green