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

Commit 1bad869

Browse files
authored
Merge pull request #261 from carlosmmatos/port-ci-to-github-actions
Porting CI from Travis to Github actions
2 parents 70b96db + c98b4cb commit 1bad869

File tree

4 files changed

+93
-125
lines changed

4 files changed

+93
-125
lines changed

.github/workflows/main.yml

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

.travis.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

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)