-
Notifications
You must be signed in to change notification settings - Fork 4
114 lines (112 loc) · 4.76 KB
/
snapshots-windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: snapshots-windows
on:
schedule:
- cron: "0 00 * * *" # Daily at 00:00 UTC
workflow_dispatch:
jobs:
snapshots-windows:
if: ${{ github.repository_owner == 'flamewing' }}
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Activity check
shell: bash
run: |
DATEUTC=$(curl -sL https://api.github.com/repos/flamewing/mdcomp/commits | jq -r '[.[]][0]' | jq -r '.commit.committer.date')
TIMESTAMP=$(date --utc -d "$DATEUTC" +%s)
DAYS=$(( ($(date --utc +%s) - $TIMESTAMP) / 86400 ))
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo REPO_ALIVE=true >> $GITHUB_ENV
else
if [ $DAYS -gt 0 ]; then
echo REPO_ALIVE=false >> $GITHUB_ENV
else
echo REPO_ALIVE=true >> $GITHUB_ENV
fi
fi
- name: Install dependencies
if: ${{ env.REPO_ALIVE == 'true' }}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW32
install:
base-devel git p7zip
mingw-w64-i686-toolchain mingw-w64-i686-binutils mingw-w64-i686-ntldd mingw-w64-i686-boost mingw-w64-i686-cmake
- name: Checkout code
if: ${{ env.REPO_ALIVE == 'true' }}
uses: actions/checkout@master
- name: Configure
if: ${{ env.REPO_ALIVE == 'true' }}
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'
- name: Build
if: ${{ env.REPO_ALIVE == 'true' }}
run: |
cmake --build build -j2
- name: Create package
if: ${{ env.REPO_ALIVE == 'true' }}
run: |
for ff in $(${MSYSTEM_PREFIX}/bin/ntldd -R build/*.exe | tr '\\' '/' | grep -io "$(cygpath -m ${MSYSTEM_PREFIX}).\+\.dll" | sort -u); do
cp $(cygpath -u "$ff") build/
done
SNAPSHOT_PATH=$(cygpath -m $(pwd -P))
echo "SNAPSHOT_PATH=${SNAPSHOT_PATH}" >> $GITHUB_ENV
export BUILDFILE="v0.2.0.$(date --utc +'%Y%m%d')"
echo "BUILDFILE=${BUILDFILE}" >> $GITHUB_ENV
cd build
"/c/Program Files/7-Zip/7z.exe" -tzip a ${SNAPSHOT_PATH}/mdcomp-${BUILDFILE}.zip -mx9 -mmt *.{exe,dll}
- name: VirusTotal Scan
if: ${{ env.REPO_ALIVE == 'true' }}
id: scan_files
uses: crazy-max/ghaction-virustotal@v2
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
github_token: ${{ github.token }}
update_release_body: true
files: |
${{ env.SNAPSHOT_PATH }}/mdcomp-${{ env.BUILDFILE }}.zip
- name: Generate VirusTotal Body
if: ${{ env.REPO_ALIVE == 'true' }}
run: |
echo "Snapshot ${{ env.BUILDFILE }}" > ${{ env.SNAPSHOT_PATH }}/body.txt
echo "" >> ${{ env.SNAPSHOT_PATH }}/body.txt
echo "🛡 [VirusTotal GitHub Action](https://github.com/crazy-max/ghaction-virustotal) analysis:" >> ${{ env.SNAPSHOT_PATH }}/body.txt
echo "" >> ${{ env.SNAPSHOT_PATH }}/body.txt
analysis="${{ steps.scan_files.outputs.analysis }}"
while read -d, -r pair; do
IFS='=' read -r filename analysisURL <<<"$pair"
echo "* [$(basename $filename)]($analysisURL)" >> ${{ env.SNAPSHOT_PATH }}/body.txt
done <<<"$analysis,"
- name: Create release
if: ${{ env.REPO_ALIVE == 'true' }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: snapshot-${{ env.BUILDFILE }}
release_name: Snapshot ${{ env.BUILDFILE }}
body_path: ${{ env.SNAPSHOT_PATH }}/body.txt
draft: true
prerelease: false
# Theses pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`.
# See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
- name: Upload snapshot
if: ${{ env.REPO_ALIVE == 'true' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.SNAPSHOT_PATH }}/mdcomp-${{ env.BUILDFILE }}.zip
asset_name: mdcomp-${{ env.BUILDFILE }}.zip
asset_content_type: application/zip
- name: Finish release
if: ${{ env.REPO_ALIVE == 'true' }}
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}