Cleaner Release Logic, Only try to import keys if repo has needed sec… (#121)

* Cleaner Release Logic, Only try to import keys if repo has needed secrets

* Remove win32 zip release

* move common Deploy items to deploy folder

Co-authored-by: Chris Rizzitello <crizzitello@ics.com>
main
crizzitello 2022-04-11 21:07:01 -04:00 committed by GitHub
parent aad875a556
commit 3a5b1156fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 165 additions and 190 deletions

View File

@ -12,27 +12,45 @@ jobs:
# This is a super hacky way to get this into a place that can actually be
# used by downstream jobs because YAML values don't allow shell
# interpolation, only github expression interpolation
store-sha8:
name: Store The Short Hash
run-info:
name: Gather Run Info
runs-on: ubuntu-latest
outputs:
sha8: ${{ steps.calc-short.outputs.sha8 }}
sha8: ${{ steps.calc-info.outputs.sha8 }}
isRelease: ${{ steps.calc-info.outputs.isRelease }}
signRelease: ${{ steps.calc-info.outputs.signRelease }}
steps:
- name: Calculate Short Hash
id: calc-short
run: echo "::set-output name=sha8::${GITHUB_SHA::8}"
- name: CheckRun Info
env:
CERT: ${{secrets.MACOS_CERT}}
id: calc-info
run: |
SIGN="false"
RELEASE="false"
if [[ "$GITHUB_REF" == *"tags/v" || "$GITHUB_REF" == *"refs/heads/release" ]]; then
RELEASE="true"
NAME="$GITHUB_REF_NAME"
fi
if [[ "$CERT" != "" ]]; then
SIGN="true"
fi
if [[ "$NAME" == "" ]]; then
NAME="continuous"
fi
echo "::set-output name=signRelease::$SIGN"
echo "::set-output name=sha8::$NAME"
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
needs: [store-sha8]
needs: run-info
strategy:
fail-fast: false
matrix:
config:
- {
name: "Linux-Qt5"
, os: ubuntu-20.04
, os: ubuntu-18.04
, QT_VERSION: 5.15.2 , QT_INST_DIR: /opt
, QT_STRING: "Qt5"
, extraCMakeConfig: "-DCMAKE_INSTALL_PREFIX=/usr -DQT_DEFAULT_MAJOR_VERSION=5"
@ -50,14 +68,14 @@ jobs:
, os: macos-latest
, QT_VERSION: 5.15.2 , QT_INST_DIR: /Users/runner
, QT_STRING: "Qt5"
, extraCMakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=5"
, extraCMakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=5 -DNOTARIZE_AS=\"John Kennedy\""
}
- {
name: "Mac-Qt6"
, os: macos-latest
, QT_VERSION: 6.2.4 , QT_INST_DIR: /Users/runner
, QT_STRING: "Qt6"
, extraCMakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=6"
, extraCMakeConfig: "-DQT_DEFAULT_MAJOR_VERSION=6 -DNOTARIZE_AS=\"John Kennedy\""
}
- {
name: "Windows-Qt5", WIN_ARCH: "x64"
@ -65,6 +83,7 @@ jobs:
, QT_VERSION: 5.15.2, QT_INST_DIR: "C:/", QTDIR: "C:/Qt/5.15.2/msvc2019_64", QT_ARCH: win64_msvc2019_64
, QT_STRING: "Qt5"
, extraCMakeConfig: "-G Ninja -DQT_DEFAULT_MAJOR_VERSION=5"
, buildTarget: "--target package"
}
- {
name: "Windows-Qt6", WIN_ARCH: "x64"
@ -72,11 +91,16 @@ jobs:
, QT_VERSION: 6.2.4, QT_INST_DIR: "C:/", QTDIR: "C:/Qt/6.2.4/msvc2019_64", QT_ARCH: win64_msvc2019_64
, QT_STRING: "Qt6"
, extraCMakeConfig: "-G Ninja -DQT_DEFAULT_MAJOR_VERSION=6"
, buildTarget: "--target package"
}
steps:
- name: Set artifact name
- name: Setup env
shell: bash
run: echo "name=ashirt-${{ needs.store-sha8.outputs.sha8 }}-${{matrix.config.QT_STRING}}-$RUNNER_OS" >> $GITHUB_ENV
run: |
echo "name=ashirt-${{ needs.run-info.outputs.sha8 }}-${{matrix.config.QT_STRING}}-$RUNNER_OS" >> $GITHUB_ENV
echo "githash=${{ needs.run-info.outputs.sha8 }}" >> $GITHUB_ENV
echo "signRelease=${{ needs.run-info.outputs.signRelease }}" >> $GITHUB_ENV
- name: Check out code
uses: actions/checkout@v3
with:
@ -97,6 +121,13 @@ jobs:
with:
arch: ${{matrix.config.WIN_ARCH}}
- name: Import Code-Signing Certificates
if: runner.os == 'macOS' && env.signRelease == 'true'
uses: Apple-Actions/import-codesign-certs@v1.0.4
with:
p12-file-base64: ${{ secrets.MACOS_CERT }}
p12-password: ${{ secrets.MACOS_PASS }}
- name: Install Qt
uses: jurplel/install-qt-action@v2.14.0
with:
@ -108,7 +139,6 @@ jobs:
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Install Dependencies
if: (runner.os == 'Windows') || (runner.os == 'Linux')
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
@ -120,128 +150,63 @@ jobs:
- name: Build
shell: bash
run: |
cmake -DCMAKE_BUILD_TYPE=Release ${{matrix.config.extraCMakeConfig}}
cmake --build .
- name: AppImage (Linux)
if: runner.os == 'Linux' && !contains(github.ref, 'tags/v') && !contains(github.ref, 'refs/heads/main') && !contains(github.ref, 'refs/heads/release-')
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DCPACK_PACKAGE_VERSION=${{env.githash}} ${{matrix.config.extraCMakeConfig}}
cmake --build . ${{ matrix.config.buildTarget }}
mkdir -p dist
if [ "$RUNNER_OS" == "Linux" ]; then
wget -qc "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget -qc "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
chmod a+x linuxdeploy*.AppImage
export VERSION=${{ needs.store-sha8.outputs.sha8 }}-${{ matrix.config.QT_STRING }}
export VERSION=${{ env.githash }}-${{ matrix.config.QT_STRING }}
${{matrix.config.linuxDeployQtPath}}
./linuxdeploy-x86_64.AppImage --appdir=appdir --output appimage \
-e ashirt \
-d linux/ashirt.desktop \
-i linux/icons/128x128/apps/ashirt.png \
-d deploy/ashirt.desktop \
-i deploy/hicolor/128x128/apps/ashirt.png \
--plugin=qt
mkdir -p dist
# file should be named ashirt-${{ needs.store-sha8.outputs.sha8 }}-x86_64.AppImage
mv ashirt*.AppImage dist/
- name: DeployPR (win)
if: runner.os == 'Windows'
shell: bash
run: |
cmake --build . --target package
mkdir -p dist
mv ashirt-*.* dist/
- name: DeployPR (mac)
if: |
matrix.config.os == 'macos-latest' &&
contains(github.ref, 'tags/v') != true &&
contains(github.ref, 'refs/heads/main') != true &&
contains(github.ref, 'refs/heads/release') != true
run: |
elif [ "$RUNNER_OS" == "macOS" ]; then
macdeployqt ashirt.app -dmg
mkdir -p dist
cp ashirt.dmg dist/ashirt.dmg
cp LICENSE dist/LICENSE
cp README.md dist/README.md
- name: Import Code-Signing Certificates
if: |
matrix.config.os == 'macos-latest' &&
(contains(github.ref, 'tags/v') || github.ref == 'refs/heads/main' || contains(github.ref, 'refs/heads/release'))
uses: Apple-Actions/import-codesign-certs@v1.0.4
with:
p12-file-base64: ${{ secrets.MACOS_CERT }}
p12-password: ${{ secrets.MACOS_PASS }}
- name: Sign Release (mac)
if: |
matrix.config.os == 'macos-latest' &&
(contains(github.ref, 'tags/v') || github.ref == 'refs/heads/main' || contains(github.ref, 'refs/heads/release'))
run: |
macdeployqt ashirt.app -dmg -always-overwrite -sign-for-notarization="John Kennedy"
mkdir -p dist
cp ashirt.dmg dist/ashirt.dmg
cp LICENSE dist/LICENSE
cp README.md dist/README.md
- name: Install gon via HomeBrew and Notarize (mac)
if: |
matrix.config.os == 'macos-latest' &&
(contains(github.ref, 'tags/v') || github.ref == 'refs/heads/main' || contains(github.ref, 'refs/heads/release'))
env:
GON_CONF: ${{ secrets.GON_CONF }}
run: |
mv ashirt.dmg ${{env.name}}.dmg
if [ "${{ env.signRelease }}" == "true" ]; then
brew tap mitchellh/gon
brew install mitchellh/gon/gon
echo "$GON_CONF" | base64 -D -i - > notarize.json
brew install mitchellh/gon/gon jq
echo "${{ secrets.GON_CONF }}" | base64 -D -i - > notarize.json
env ID="${{ env.name }}.dmg" cat gon.json |jq '.notarize[0].path = env.ID'
gon notarize.json
fi
fi
mv ashirt-*.* dist/
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.name }}
path: dist
name: ashirt-${{env.githash}}
path: dist/ashirt-*.*
release:
name: Create GitHub Release
if: contains(github.ref, 'tags/v')
needs: [store-sha8, build]
name: Release
needs: build
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
publish:
if: contains(github.ref, 'tags/v')
needs: [store-sha8, build, release]
runs-on: ubuntu-latest
strategy:
matrix:
platform: [macOS, Linux, Windows]
steps:
- name: Set Version
run: echo "version=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV
- name: Download Previous Artifacts
- name: Download Files
uses: actions/download-artifact@v3
- name: Deploy Continuous
if: github.ref == 'refs/heads/master'
uses: "marvinpinto/action-automatic-releases@latest"
with:
name: ashirt-${{ needs.store-sha8.outputs.sha8 }}-${{ matrix.platform }}
path: ashirt-${{ env.version }}-${{ matrix.platform }}
- name: Produce Zip
run: zip -r ashirt-${{ env.version }}-${{ matrix.platform }}.zip ashirt-${{ env.version }}-${{ matrix.platform }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "continuous"
prerelease: false
title: "Continuous Build"
files: dist/ashirt-*.*
- name: Deploy Tag
if: needs.run-info.outputs.isRelease == 'true'
uses: "marvinpinto/action-automatic-releases@latest"
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ashirt-${{ env.version }}-${{ matrix.platform }}.zip
asset_name: ashirt-${{ env.version }}-${{ matrix.platform }}.zip
asset_content_type: application/zip
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ github.ref }}
prerelease: false
title: ${{ github.ref }}
files: dist/ashirt-*.*

View File

@ -8,7 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
option(NOTARIZE_AS "Attempt get mac bundle notarization as Provided user" "")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git)
find_package(Git)
if(GIT_FOUND)
@ -50,8 +50,6 @@ else()
add_definitions(-DCOMMIT_HASH="")
add_definitions(-DVERSION_TAG="")
add_definitions(-DSOURCE_CONTROL_REPO="")
add_definitions(-DVERSION_TAG_PLAIN "v0.0.0-development")
add_definitions(-DCOMMIT_HASH_PLAIN "Unknown")
endif()
message(STATUS "VERSION: ${CMAKE_PROJECT_VERSION}")
@ -69,6 +67,8 @@ find_package(Qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED COMPONENTS
include_directories(${Qt${QT_DEFAULT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}/qpa)
include_directories(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(deploy)
set(ASHIRT_SOURCES
src/appconfig.h
src/appsettings.h
@ -134,13 +134,24 @@ set(ASHIRT_SOURCES
res_icons.qrc
res_migrations.qrc
)
## Locate the deploy app for later use
get_target_property(qmake_executable Qt${QT_DEFAULT_MAJOR_VERSION}::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${qmake_executable}" DIRECTORY)
if(WIN32 OR APPLE)
if(WIN32)
set(deployqtapp windeployqt)
elseif(APPLE)
set(deployqtapp macdeployqt)
endif()
find_program(PLATFORMDEPLOYQT ${deployqtapp} HINTS "${_qt_bin_dir}")
endif()
if(APPLE)
set(ASHIRT_PLATFORM_EX_SRC ${CMAKE_SOURCE_DIR}/icons/ashirt.icns)
set(ASHIRT_PLATFORM_EX_SRC ${CMAKE_SOURCE_DIR}/deploy/ashirt.icns)
set_source_files_properties(${ASHIRT_PLATFORM_EX_SRC} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
elseif(WIN32)
set(CMAKE_PREFIX_PATH $ENV{QTDIR})
set(ASHIRT_PLATFORM_EX_SRC ${CMAKE_SOURCE_DIR}/windows/ashirt.rc)
set(ASHIRT_PLATFORM_EX_SRC ${CMAKE_SOURCE_DIR}/deploy/ashirt.rc)
endif()
#MACOSX_BUNDLE Make it a bundle on Mac OS
@ -166,69 +177,33 @@ target_link_libraries ( ashirt
if(APPLE)
find_library(CARBON_LIBRARY Carbon)
target_link_libraries(ashirt PRIVATE ${CARBON_LIBRARY})
elseif(UNIX AND NOT APPLE)
target_link_libraries(ashirt PRIVATE xcb xcb-keysyms pthread)
elseif(WIN32)
target_link_libraries(ashirt PRIVATE user32)
endif()
if(UNIX)
install(TARGETS ashirt
BUNDLE DESTINATION .
RUNTIME DESTINATION bin
)
elseif(WIN32)
install(TARGETS ashirt RUNTIME DESTINATION .)
endif()
if(UNIX AND NOT APPLE)
install(FILES ${CMAKE_SOURCE_DIR}/linux/icons/* DESTINATION share/icons/hicolor)
install(FILES ${CMAKE_SOURCE_DIR}/linux/ashirt.desktop DESTINATION share/applictions)
endif()
##CPACK
set(CPACK_STRIP_FILES TRUE)
get_target_property(_qmake_executable Qt${QT_DEFAULT_MAJOR_VERSION}::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_NAME "ashirt")
set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Qt${QT_DEFAULT_MAJOR_VERSION}-Windows")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ashirt")
set(CPACK_NSIS_DISPLAY_NAME ${CMAKE_PACKAGE_NAME})
set(CPACK_NSIS_COMPRESSOR lzma)
set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/windows/ashirt.ico")
set(CPACK_NSIS_INSTALLED_ICON_NAME ashirt.exe)
set(CPACK_NSIS_MENU_LINKS "ashirt.exe" "ashirt")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"RMDir /r '$INSTDIR'"
)
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
find_program(WINDEPLOYQT windeployqt HINTS "${_qt_bin_dir}")
if(${QT_DEFAULT_MAJOR_VERSION} MATCHES "5")
if(NOTARIZE_AS STREQUAL "")
add_custom_command(
TARGET ashirt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/qtDeploy
COMMAND ${WINDEPLOYQT} --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins --no-compiler-runtime --no-system-d3d-compiler --no-angle --no-webkit2 --no-quick-import --no-translations --dir ${CMAKE_BINARY_DIR}/qtDeploy $<TARGET_FILE:ashirt>
COMMAND ${PLATFORMDEPLOYQT} ${CMAKE_BINARY_DIR}/ashirt.app
)
else()
add_custom_command(
TARGET ashirt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/qtDeploy
COMMAND ${WINDEPLOYQT} --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins --no-compiler-runtime --no-system-d3d-compiler --no-quick-import --no-translations --dir ${CMAKE_BINARY_DIR}/qtDeploy $<TARGET_FILE:ashirt>
COMMAND ${PLATFORMDEPLOYQT} ${CMAKE_BINARY_DIR}/ashirt.app -sign-for-notarization=${NOTARIZE_AS}
)
endif()
install(
DIRECTORY ${CMAKE_BINARY_DIR}/qtDeploy/
DESTINATION .
FILES_MATCHING PATTERN "*.*"
install(TARGETS ashirt BUNDLE DESTINATION .)
elseif(UNIX AND NOT APPLE)
target_link_libraries(ashirt PRIVATE xcb xcb-keysyms pthread)
install(TARGETS ashirt BUNDLE DESTINATION bin)
elseif(WIN32)
target_link_libraries(ashirt PRIVATE user32)
install(TARGETS ashirt RUNTIME DESTINATION .)
if(${QT_DEFAULT_MAJOR_VERSION} MATCHES "5")
add_custom_command(
TARGET ashirt POST_BUILD
COMMAND ${PLATFORMDEPLOYQT} $<TARGET_FILE:ashirt> --no-compiler-runtime --no-system-d3d-compiler --no-quick-import --no-translations --no-angle --no-webkit2 --no-opengl-sw --dir ${CMAKE_BINARY_DIR}/qtDeploy --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins
)
else()
add_custom_command(
TARGET ashirt POST_BUILD
COMMAND ${PLATFORMDEPLOYQT} $<TARGET_FILE:ashirt> --no-compiler-runtime --no-system-d3d-compiler --no-quick-import --no-translations --no-opengl-sw --dir ${CMAKE_BINARY_DIR}/qtDeploy --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins
)
set(CPACK_GENERATOR "ZIP;NSIS")
endif()
INCLUDE (CPack)
endif()

35
deploy/CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
if(APPLE OR WIN32)
install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION .)
elseif(UNIX AND NOT APPLE)
install(DIRECTORY hicolor DESTINATION share/icons)
install(FILES ashirt.desktop DESTINATION share/applictions)
endif()
##CPACK
set(CPACK_STRIP_FILES TRUE)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_NAME "ashirt")
if(NOT CPACK_PACKAGE_VERSION)
set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Qt${QT_DEFAULT_MAJOR_VERSION}-Windows")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "ashirt")
set(CPACK_NSIS_DISPLAY_NAME ${CMAKE_PACKAGE_NAME})
set(CPACK_NSIS_COMPRESSOR lzma)
set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/deploy/ashirt.ico")
set(CPACK_NSIS_INSTALLED_ICON_NAME ashirt.exe)
set(CPACK_NSIS_MENU_LINKS "ashirt.exe" "ashirt")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"RMDir /r '$INSTDIR'"
)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/qtDeploy/
DESTINATION .
FILES_MATCHING PATTERN "*.*"
)
set(CPACK_GENERATOR "NSIS")
endif()
INCLUDE (CPack)

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 322 B

View File

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 419 B

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 529 B

View File

Before

Width:  |  Height:  |  Size: 797 B

After

Width:  |  Height:  |  Size: 797 B

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 1015 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB