Skip to content
This repository was archived by the owner on Sep 27, 2024. It is now read-only.

Commit 84acb90

Browse files
Carlos Matoscarlosmmatos
authored andcommitted
Porting CI from Travis to Github actions
New Github Actions file follows similar convention to Travis with a few minor differences. By default - GHA does not let you use normal syntax to skip jobs when testing. The current setup allows for a dev to use either [skip ci] or [skip-ci] in order to not kick off a job. This is similar to other CI tools except that in this instance we have full control of the syntax we want to check for in order to skip a job. Other fixes include additional verbosity on the build-for-osx and osx-create-dmg scripts. There is also a new travis-ci file that is deprecated, but shown in case someone would like to use it for further testing.
1 parent 70b96db commit 84acb90

File tree

4 files changed

+177
-78
lines changed

4 files changed

+177
-78
lines changed

.github/workflows/main.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: OpenScap Workbench CI
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on: push
6+
7+
jobs:
8+
build-macos:
9+
# The type of runner that the job will run on
10+
runs-on: macos-latest
11+
# Allows you to skip a ci job - [skip ci] or [skip-ci]
12+
if: (!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'skip-ci'))
13+
steps:
14+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
15+
- uses: actions/checkout@v2
16+
17+
# *before_install* port
18+
- name: Install additional packages
19+
run: |
20+
brew install jq
21+
brew install qt5
22+
brew install asciidoc
23+
brew install pkg-config
24+
brew install doxygen
25+
brew install opendbx
26+
brew install popt
27+
brew install swig
28+
brew install upx
29+
npm install -g appdmg
30+
echo "::add-path::/usr/local/opt/qt/bin"
31+
32+
# Runs a set of commands using the runners shell
33+
- name: Run openSCAP build process
34+
run: |
35+
git clone --depth 1 https://github.com/openscap/openscap.git -b master
36+
pushd openscap/build
37+
cmake -DENABLE_PROBES=FALSE ../
38+
make -j 4
39+
make install
40+
popd
41+
42+
# Build OSX image
43+
- name: Build OSX image
44+
run: |
45+
chmod +x ./build-for-osx.sh
46+
./build-for-osx.sh
47+
REL_TAG=`curl -s "https://github.com/ComplianceAsCode/content/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}'`
48+
REL_TAG_NUM=`echo ${REL_TAG} | cut -d"v" -f2`
49+
DWN_LINK=https://github.com/ComplianceAsCode/content/releases/download/${REL_TAG}/scap-security-guide-${REL_TAG_NUM}.zip
50+
if [ -z "${DWN_LINK}" ]; then echo 'Could not get the ZIP URL! It is empty!'; exit 1; fi
51+
wget "${DWN_LINK}" -O ssg.zip
52+
mkdir -p `pwd`/build-osx/scap-workbench.app/Contents/Resources/ssg/ && unzip ssg.zip && cp -a scap-security-guide-*/* `pwd`/build-osx/scap-workbench.app/Contents/Resources/ssg/
53+
cd build-osx && bash osx-create-dmg.sh
54+
55+
# Get tag release version (1.2.X etc,.)
56+
- name: Get the release version
57+
id: get_version
58+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
59+
60+
# Deploy package to release
61+
- name: Release
62+
uses: softprops/action-gh-release@v1
63+
if: startsWith(github.ref, 'refs/tags/')
64+
with:
65+
files: build-osx/scap-workbench-${{ steps.get_version.outputs.VERSION }}.dmg
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+

.travis.yml.deprecated

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
os: osx
2+
3+
# Testing: Define jobs to include macOS 10.13 - present for compatibility testing.
4+
# Travis CI has a lot more OS options than Github Actions currently has.
5+
#
6+
# jobs:
7+
# include:
8+
# - os: osx
9+
# osx_image: xcode9.4
10+
# - os: osx
11+
# osx_image: xcode10
12+
# - os: osx
13+
# osx_image: xcode10.1
14+
# - os: osx
15+
# osx_image: xcode10.2
16+
# - os: osx
17+
# osx_image: xcode10.3
18+
# - os: osx
19+
# osx_image: xcode11
20+
# - os: osx
21+
# osx_image: xcode11.1
22+
# - os: osx
23+
# osx_image: xcode11.2
24+
# - os: osx
25+
# osx_image: xcode11.3
26+
# - os: osx
27+
# osx_image: xcode11.4
28+
29+
sudo: required
30+
31+
language: cpp
32+
33+
compiler:
34+
- gcc
35+
36+
env:
37+
- PATH="/usr/local/opt/qt/bin:$PATH"
38+
39+
before_install:
40+
- brew update
41+
- brew install jq || brew upgrade jq
42+
- brew install qt || true
43+
- brew install asciidoc || brew upgrade asciidoc
44+
- brew install pkg-config || brew upgrade pkg-config
45+
- brew install doxygen || brew upgrade doxygen
46+
- brew install opendbx || brew upgrade opendbx
47+
- brew install popt || brew upgrade popt
48+
- brew install swig || brew upgrade swig
49+
- brew install upx || brew upgrade upx
50+
- brew install node || brew upgrade node
51+
- npm install -g appdmg
52+
53+
before_script:
54+
- git clone --depth 1 https://github.com/openscap/openscap.git -b master
55+
- pushd openscap/build
56+
- cmake -DENABLE_PROBES=FALSE ../
57+
- make -j 4
58+
- make install
59+
- popd
60+
61+
script:
62+
- ./build-for-osx.sh
63+
# Parse release page json to obtain link to latest content zip file and download it
64+
- |
65+
REL_TAG=`curl -s "https://github.com/ComplianceAsCode/content/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}'`
66+
REL_TAG_NUM=`echo ${REL_TAG} | cut -d"v" -f2`
67+
DWN_LINK=https://github.com/ComplianceAsCode/content/releases/download/${REL_TAG}/scap-security-guide-${REL_TAG_NUM}.zip
68+
if [ -z "${DWN_LINK}" ] ; then
69+
echo "Could not get the ZIP URL! It is empty!"
70+
exit 1
71+
fi
72+
- wget "${DWN_LINK}" -O ssg.zip
73+
- mkdir -p `pwd`/build-osx/scap-workbench.app/Contents/Resources/ssg/ && unzip ssg.zip && cp -a scap-security-guide-*/* `pwd`/build-osx/scap-workbench.app/Contents/Resources/ssg/
74+
- cd build-osx && bash osx-create-dmg.sh
75+
76+
deploy:
77+
provider: releases
78+
api_key: $GITHUB_TOKEN
79+
file: scap-workbench-$TRAVIS_TAG.dmg
80+
skip_cleanup: true
81+
on:
82+
tags: true

build-for-osx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set -e
1+
set -ex
22

33
mkdir -p build-osx/
44
pushd build-osx/

osx-create-dmg.sh.in

Lines changed: 26 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
set -e
3+
set -ex
44

55
# Original by Andy Maloney
66
# http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
@@ -29,11 +29,8 @@ _BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9
2929
if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then
3030
echo "WARNING: The background image's DPI is not 72. This will result in distorted backgrounds on Mac OS X 10.7+."
3131
echo " I will convert it to 72 DPI for you."
32-
3332
_DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}"
34-
3533
sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_IMG} --out ${_DMG_BACKGROUND_TMP}
36-
3734
DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}"
3835
fi
3936

@@ -62,79 +59,31 @@ fi
6259

6360
popd
6461

65-
# figure out how big our DMG needs to be
66-
# assumes our contents are at least 1M!
67-
SIZE=`du -sh "${STAGING_DIR}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
68-
SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`
69-
70-
if [ $? -ne 0 ]; then
71-
echo "Error: Cannot compute size of staging dir"
72-
exit
73-
fi
74-
75-
# create the temp DMG file
76-
hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \
77-
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"
78-
79-
echo "Created DMG: ${DMG_TMP}"
80-
81-
# mount it and save the device
82-
DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \
83-
egrep '^/dev/' | sed 1q | awk '{print $1}')
84-
85-
sleep 2
86-
87-
# add a link to the Applications dir
88-
echo "Add link to /Applications"
89-
pushd /Volumes/"${VOL_NAME}"
90-
ln -s /Applications
91-
popd
92-
93-
# add a background image
94-
mkdir /Volumes/"${VOL_NAME}"/.background
95-
cp "${DMG_BACKGROUND_IMG}" /Volumes/"${VOL_NAME}"/.background/
96-
DMG_BACKGROUND_IMG_BASENAME=`basename ${DMG_BACKGROUND_IMG}`
97-
98-
# add COPYING
99-
cp "@CMAKE_SOURCE_DIR@/COPYING" /Volumes/"${VOL_NAME}"/
100-
101-
# tell the Finder to resize the window, set the background,
102-
# change the icon size, place the icons in the right position, etc.
103-
echo '
104-
tell application "Finder"
105-
tell disk "'${VOL_NAME}'"
106-
open
107-
set current view of container window to icon view
108-
set toolbar visible of container window to false
109-
set statusbar visible of container window to false
110-
set the bounds of container window to {400, 100, 927, 440}
111-
set viewOptions to the icon view options of container window
112-
set arrangement of viewOptions to not arranged
113-
set icon size of viewOptions to 72
114-
set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG_BASENAME}'"
115-
set position of item "'${APP_NAME}'.app" of container window to {160, 225}
116-
set position of item "Applications" of container window to {360, 225}
117-
set position of item "COPYING" of container window to {460, 275}
118-
close
119-
open
120-
update without registering applications
121-
delay 2
122-
end tell
123-
end tell
124-
' | osascript
125-
126-
sync
127-
128-
# unmount it
129-
hdiutil detach "${DEVICE}"
130-
131-
# now make the final image a compressed disk image
132-
echo "Creating compressed image"
133-
hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"
134-
135-
# clean up
136-
rm -rf "${DMG_TMP}"
137-
rm -rf "${STAGING_DIR}"
62+
#------------- Updated section to support creating a dmg in macOS 10.13+ -------------#
63+
# Changes made by Carlos Matos <[email protected]
64+
# Issues identified when trying to port CI from Travis to Github Actions. Using macOS 10.14+
65+
# would cause the CI job to fail due to security enhancements made after High Sierra. This
66+
# was essentially causing the original applescript to timeout after it's default 2 minute waiting
67+
# period. After making several attempts to work around this issue - it became clear that this was
68+
# going to take too much effort - if it even would work at all. I began looking at alternative
69+
# solutions, which lead me to a couple of open source projects created by people who simply wanted
70+
# to make the process of creating a dmg easier. After testing dmgbuild and appdmg, I settled with
71+
# appdmg since it was easy to port our existing configuration to it.
72+
cat << EOF > scapwb.json
73+
{
74+
"title": "SCAP Workbench",
75+
"background": "${DMG_BACKGROUND_IMG}",
76+
"format": "UDZO",
77+
"window": { "position": { "x": 300, "y": 300 } },
78+
"contents": [
79+
{ "x": 360, "y": 225, "type": "link", "path": "/Applications" },
80+
{ "x": 160, "y": 225, "type": "file", "path": "${STAGING_DIR}/${APP_NAME}.app" }
81+
]
82+
}
83+
EOF
84+
85+
echo "Creating customized DMG image..."
86+
appdmg scapwb.json ${DMG_FINAL}
13887

13988
echo 'Done.'
14089

0 commit comments

Comments
 (0)