parent
069f43b8f7
commit
9426ce6ef5
@ -0,0 +1,33 @@ |
|||||||
|
name: CI |
||||||
|
on: [push] |
||||||
|
jobs: |
||||||
|
|
||||||
|
build: |
||||||
|
name: Build |
||||||
|
runs-on: macos-latest |
||||||
|
strategy: |
||||||
|
matrix: |
||||||
|
goVer: [1.13, 1.14] |
||||||
|
|
||||||
|
steps: |
||||||
|
- name: Set up Go ${{ matrix.goVer }} |
||||||
|
uses: actions/setup-go@v1 |
||||||
|
with: |
||||||
|
go-version: ${{ matrix.goVer }} |
||||||
|
id: go |
||||||
|
|
||||||
|
- name: Check out code into the Go module directory |
||||||
|
uses: actions/checkout@v2 |
||||||
|
|
||||||
|
- name: Get dependencies |
||||||
|
run: | |
||||||
|
go get -v -t -d ./... |
||||||
|
go get gopkg.in/check.v1 |
||||||
|
- name: Build |
||||||
|
run: go build -v . |
||||||
|
|
||||||
|
- name: Format |
||||||
|
run: diff -u <(echo -n) <(gofmt -d .) |
||||||
|
|
||||||
|
- name: Test |
||||||
|
run: go test -v ./... |
@ -1,39 +1,147 @@ |
|||||||
on: release |
name: Build Hack-Browser-Data Release |
||||||
name: Build Release |
on: |
||||||
|
release: |
||||||
|
types: [created] |
||||||
|
|
||||||
jobs: |
jobs: |
||||||
release-darwin-amd64: |
build: |
||||||
name: release darwin/amd64 |
name: Build Binary |
||||||
runs-on: macos-latest |
runs-on: ${{ matrix.os }} |
||||||
steps: |
strategy: |
||||||
- uses: actions/checkout@master |
matrix: |
||||||
- name: compile and release |
os: [windows-latest, macos-latest] |
||||||
uses: ngs/go-release.action@v1.0.1 |
arch: [amd64] |
||||||
env: |
# We sometimes use different verbiage for things (e.g. "darwin" |
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
# for the GOOS build flag and "osx" in the actual release ZIP). |
||||||
GOARCH: amd64 |
# We need to specify those here. |
||||||
GOOS: darwin |
include: |
||||||
EXTRA_FILES: "LICENSE" |
- os: windows-latest |
||||||
release-windows-386: |
goos: windows |
||||||
name: release windows/386 |
bin: 'hack-browser-data.exe' |
||||||
runs-on: windows-latest |
releaseos: windows |
||||||
steps: |
- os: macos-latest |
||||||
- uses: actions/checkout@master |
goos: darwin |
||||||
- name: compile and release |
bin: 'hack-browser-data' |
||||||
uses: ngs/go-release.action@v1.0.1 |
releaseos: osx |
||||||
env: |
# Don't build windows-32bit due to missing MinGW dependencies |
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
# Don't build osx-32bit due to eventual drop in Go support |
||||||
GOARCH: "386" |
exclude: |
||||||
GOOS: windows |
- os: windows-latest |
||||||
EXTRA_FILES: "LICENSE" |
arch: '386' |
||||||
release-windows-amd64: |
- os: macos-latest |
||||||
name: release windows/amd64 |
arch: '386' |
||||||
runs-on: ubuntu-latest |
steps: |
||||||
steps: |
- name: Set up Go |
||||||
- uses: actions/checkout@master |
uses: actions/setup-go@v2 |
||||||
- name: compile and release |
with: |
||||||
uses: ngs/go-release.action@v1.0.1 |
go-version: 1.14 |
||||||
env: |
# - if: matrix.os == 'ubuntu-latest' |
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
# run: sudo apt-get update && sudo apt-get install -y gcc-multilib |
||||||
GOARCH: amd64 |
# - if: matrix.arch == '386' |
||||||
GOOS: windows |
# run: echo "::set-env name=RELEASE::gophish-${{ github.event.release.tag_name }}-${{ matrix.releaseos}}-32bit" |
||||||
EXTRA_FILES: "LICENSE" |
- if: matrix.arch == 'amd64' |
||||||
|
run: echo "::set-env name=RELEASE::hack-browser-data-${{ github.event.release.tag_name}}-${{ matrix.releaseos}}-64bit" |
||||||
|
- uses: actions/checkout@v2 |
||||||
|
- name: Build ${{ matrix.goos }}/${{ matrix.arch }} |
||||||
|
run: go build -o ${{ matrix.bin }} |
||||||
|
env: |
||||||
|
GOOS: ${{ matrix.goos }} |
||||||
|
GOARCH: ${{ matrix.arch }} |
||||||
|
CGO_ENABLED: 1 |
||||||
|
- name: Upload to artifacts |
||||||
|
uses: actions/upload-artifact@v2 |
||||||
|
with: |
||||||
|
name: ${{ env.RELEASE }} |
||||||
|
path: ${{ matrix.bin }} |
||||||
|
|
||||||
|
package: |
||||||
|
name: Package Assets |
||||||
|
runs-on: ubuntu-latest |
||||||
|
needs: build |
||||||
|
steps: |
||||||
|
- uses: actions/checkout@v2 |
||||||
|
- uses: actions/download-artifact@v2 |
||||||
|
with: |
||||||
|
path: bin |
||||||
|
- name: Package Releases |
||||||
|
run: | |
||||||
|
mkdir releases; |
||||||
|
for RELEASE_DIR in bin/* |
||||||
|
do |
||||||
|
echo "Creating release $RELEASE_DIR" |
||||||
|
for BINARY in $RELEASE_DIR/* |
||||||
|
do |
||||||
|
cp $BINARY .; |
||||||
|
zip -r releases/$(basename $RELEASE_DIR).zip \ |
||||||
|
$(basename ${BINARY}) \ |
||||||
|
static/js/dist \ |
||||||
|
static/js/src/vendor/ckeditor \ |
||||||
|
static/css/dist \ |
||||||
|
static/images \ |
||||||
|
static/font \ |
||||||
|
static/db \ |
||||||
|
db \ |
||||||
|
templates \ |
||||||
|
README.md \ |
||||||
|
VERSION \ |
||||||
|
LICENSE \ |
||||||
|
config.json; |
||||||
|
rm $BINARY; |
||||||
|
done |
||||||
|
done |
||||||
|
- name: Upload to artifacts |
||||||
|
uses: actions/upload-artifact@v2 |
||||||
|
with: |
||||||
|
name: releases |
||||||
|
path: releases/*.zip |
||||||
|
|
||||||
|
upload: |
||||||
|
name: Upload to the Release |
||||||
|
runs-on: ubuntu-latest |
||||||
|
needs: package |
||||||
|
steps: |
||||||
|
- uses: actions/download-artifact@v2 |
||||||
|
with: |
||||||
|
name: releases |
||||||
|
path: releases/ |
||||||
|
# I would love to use @actions/upload-release-asset, but they don't |
||||||
|
# support wildcards in the asset path. Ref #9, #24, and #47 |
||||||
|
- name: Upload Archives to Release |
||||||
|
env: |
||||||
|
UPLOAD_URL: ${{ github.event.release.upload_url }} |
||||||
|
API_HEADER: "Accept: application/vnd.github.v3+json" |
||||||
|
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}" |
||||||
|
run: | |
||||||
|
UPLOAD_URL=$(echo -n $UPLOAD_URL | sed s/\{.*//g) |
||||||
|
for FILE in releases/* |
||||||
|
do |
||||||
|
echo "Uploading ${FILE}"; |
||||||
|
curl \ |
||||||
|
-H "${API_HEADER}" \ |
||||||
|
-H "${AUTH_HEADER}" \ |
||||||
|
-H "Content-Type: $(file -b --mime-type ${FILE})" \ |
||||||
|
--data-binary "@${FILE}" \ |
||||||
|
"${UPLOAD_URL}?name=$(basename ${FILE})"; |
||||||
|
done |
||||||
|
- name: Generate SHA256 Hashes |
||||||
|
env: |
||||||
|
API_HEADER: "Accept: application/vnd.github.v3+json" |
||||||
|
AUTH_HEADER: "Authorization: token ${{ secrets.GITHUB_TOKEN }}" |
||||||
|
RELEASE_URL: ${{ github.event.release.url }} |
||||||
|
run: | |
||||||
|
HASH_TABLE="| SHA256 Hash | Filename |" |
||||||
|
HASH_TABLE="${HASH_TABLE}\n|-----|-----|\n" |
||||||
|
for FILE in releases/* |
||||||
|
do |
||||||
|
FILENAME=$(basename ${FILE}) |
||||||
|
HASH=$(sha256sum ${FILE} | cut -d ' ' -f 1) |
||||||
|
HASH_TABLE="${HASH_TABLE}|${HASH}|${FILENAME}|\n" |
||||||
|
done |
||||||
|
echo "${HASH_TABLE}" |
||||||
|
curl \ |
||||||
|
-XPATCH \ |
||||||
|
-H "${API_HEADER}" \ |
||||||
|
-H "${AUTH_HEADER}" \ |
||||||
|
-H "Content-Type: application/json" \ |
||||||
|
-d "{\"body\": \"${HASH_TABLE}\"}" \ |
||||||
|
"${RELEASE_URL}"; |
||||||
|
@ -1,26 +0,0 @@ |
|||||||
#!/bin/sh |
|
||||||
|
|
||||||
set -eux |
|
||||||
|
|
||||||
PROJECT_ROOT="/go/src/github.com/${GITHUB_REPOSITORY}" |
|
||||||
|
|
||||||
mkdir -p $PROJECT_ROOT |
|
||||||
rmdir $PROJECT_ROOT |
|
||||||
ln -s $GITHUB_WORKSPACE $PROJECT_ROOT |
|
||||||
cd $PROJECT_ROOT |
|
||||||
go get -v ./... |
|
||||||
|
|
||||||
EXT='' |
|
||||||
|
|
||||||
if [ $GOOS == 'windows' ]; then |
|
||||||
EXT='.exe' |
|
||||||
fi |
|
||||||
|
|
||||||
if [ -x "./build.sh" ]; then |
|
||||||
OUTPUT=`./build.sh "${CMD_PATH}"` |
|
||||||
else |
|
||||||
go build "${CMD_PATH}" |
|
||||||
OUTPUT="${PROJECT_NAME}${EXT}" |
|
||||||
fi |
|
||||||
|
|
||||||
echo ${OUTPUT} |
|
@ -1,54 +0,0 @@ |
|||||||
|
|
||||||
#!/bin/sh |
|
||||||
|
|
||||||
set -eux |
|
||||||
|
|
||||||
if [ -z "${CMD_PATH+x}" ]; then |
|
||||||
echo "::warning file=entrypoint.sh,line=6,col=1::CMD_PATH not set" |
|
||||||
export CMD_PATH="" |
|
||||||
fi |
|
||||||
|
|
||||||
FILE_LIST=`/build.sh` |
|
||||||
|
|
||||||
#echo "::warning file=/build.sh,line=1,col=5::${FILE_LIST}" |
|
||||||
|
|
||||||
EVENT_DATA=$(cat $GITHUB_EVENT_PATH) |
|
||||||
echo $EVENT_DATA | jq . |
|
||||||
UPLOAD_URL=$(echo $EVENT_DATA | jq -r .release.upload_url) |
|
||||||
UPLOAD_URL=${UPLOAD_URL/\{?name,label\}/} |
|
||||||
RELEASE_NAME=$(echo $EVENT_DATA | jq -r .release.tag_name) |
|
||||||
PROJECT_NAME=$(basename $GITHUB_REPOSITORY) |
|
||||||
NAME="${NAME:-${PROJECT_NAME}_${RELEASE_NAME}}_${GOOS}_${GOARCH}" |
|
||||||
|
|
||||||
if [ -z "${EXTRA_FILES+x}" ]; then |
|
||||||
echo "::warning file=entrypoint.sh,line=22,col=1::EXTRA_FILES not set" |
|
||||||
fi |
|
||||||
|
|
||||||
FILE_LIST="${FILE_LIST} ${EXTRA_FILES}" |
|
||||||
|
|
||||||
FILE_LIST=`echo "${FILE_LIST}" | awk '{$1=$1};1'` |
|
||||||
|
|
||||||
|
|
||||||
if [ $GOOS == 'windows' ]; then |
|
||||||
ARCHIVE=tmp.zip |
|
||||||
zip -9r $ARCHIVE ${FILE_LIST} |
|
||||||
else |
|
||||||
ARCHIVE=tmp.tgz |
|
||||||
tar cvfz $ARCHIVE ${FILE_LIST} |
|
||||||
fi |
|
||||||
|
|
||||||
CHECKSUM=$(md5sum ${ARCHIVE} | cut -d ' ' -f 1) |
|
||||||
|
|
||||||
curl \ |
|
||||||
-X POST \ |
|
||||||
--data-binary @${ARCHIVE} \ |
|
||||||
-H 'Content-Type: application/octet-stream' \ |
|
||||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ |
|
||||||
"${UPLOAD_URL}?name=${NAME}.${ARCHIVE/tmp./}" |
|
||||||
|
|
||||||
curl \ |
|
||||||
-X POST \ |
|
||||||
--data $CHECKSUM \ |
|
||||||
-H 'Content-Type: text/plain' \ |
|
||||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ |
|
||||||
"${UPLOAD_URL}?name=${NAME}_checksum.txt" |
|
Loading…
Reference in new issue