forked from wgpsec/ENScan_GO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: build | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest] | ||
go-version: [1.17] | ||
name: Build | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up xgo | ||
run: | | ||
docker pull techknowlogick/xgo:latest | ||
go install src.techknowlogick.com/xgo@latest | ||
sudo apt install upx | ||
- name: Build | ||
run: | | ||
ls -a | ||
pwd | ||
bash build.sh | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: artifact | ||
path: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
release: | ||
strategy: | ||
matrix: | ||
platform: [ ubuntu-latest ] | ||
go-version: [ 1.17 ] | ||
name: Build | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Get version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
|
||
- name: Get Set | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo "app_name=enscan-${{steps.get_version.outputs.VERSION}}" >> $GITHUB_ENV | ||
builtAt=$(date +'%F %T %z') | ||
goVersion=$(go version | sed 's/go version //') | ||
gitAuthor=${{ github.actor }} | ||
buildSha=${{ github.sha }} | ||
gitTag=${{steps.get_version.outputs.VERSION}} | ||
echo 'ldflags<<EOF' >> $GITHUB_ENV | ||
echo "-w -s" >>$GITHUB_ENV | ||
echo "-X 'github.com/wgpsec/ENScan/common.BuiltAt=$builtAt' ">>$GITHUB_ENV | ||
echo "-X 'github.com/wgpsec/ENScan/common.GoVersion=$goVersion' ">>$GITHUB_ENV | ||
echo "-X 'github.com/wgpsec/ENScan/common.GitAuthor=$gitAuthor' ">>$GITHUB_ENV | ||
echo "-X 'github.com/wgpsec/ENScan/common.BuildSha=$buildSha' ">>$GITHUB_ENV | ||
echo " -X 'github.com/wgpsec/ENScan/common.GitTag=$gitTag' ">>$GITHUB_ENV | ||
echo 'EOF' >> $GITHUB_ENV | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get -y install gcc-mingw-w64-x86-64 | ||
sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross | ||
sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross | ||
go get -v -t -d ./... | ||
if [ -f Gopkg.toml ]; then | ||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
dep ensure | ||
fi | ||
- name: Build linux | ||
run: | | ||
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags="${{env.ldflags}}" -o ${{env.app_name}}-linux-amd64 enscan.go | ||
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags="${{env.ldflags}}" -o ${{env.app_name}}-linux-arm64 enscan.go | ||
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -ldflags="${{env.ldflags}}" -o ${{env.app_name}}-linux-arm enscan.go | ||
- name: Build windows | ||
run: | | ||
CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags="${{env.ldflags}}" -o ${{env.app_name}}-windows-amd64.exe enscan.go | ||
- name: Build linux_386 | ||
run: | | ||
sudo apt-get -y install libc6-dev-i386 | ||
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -ldflags="${{env.ldflags}}" -o ${{env.app_name}}-linux-386 enscan.go | ||
- name: Build darwin | ||
run: | | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="${{env.ldflags}}" -gcflags '-N -l' -o ${{env.app_name}}-darwin-amd64 enscan.go | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="${{env.ldflags}}" -gcflags '-N -l' -o ${{env.app_name}}-darwin-arm64 enscan.go | ||
- name: compress | ||
run: | | ||
mkdir "build" | ||
mv ${{env.app_name}}-* build | ||
cd build || exit | ||
find . -type f -print0 | xargs -0 md5sum > md5.txt | ||
cat md5.txt | ||
mkdir compress | ||
mv md5.txt compress | ||
for i in `find . -type f -name "${{env.app_name}}-linux-*"` | ||
do | ||
tar -czvf compress/"$i".tar.gz "$i" | ||
done | ||
for i in `find . -type f -name "${{env.app_name}}-darwin-*"` | ||
do | ||
tar -czvf compress/"$i".tar.gz "$i" | ||
done | ||
for i in `find . -type f -name "${{env.app_name}}-windows-*"` | ||
do | ||
zip compress/$(echo $i | sed 's/\.[^.]*$//').zip "$i" | ||
done | ||
- name: Build Changelog | ||
id: github_release | ||
uses: mikepenz/release-changelog-builder-action@main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: ${{steps.github_release.outputs.changelog}} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: build/compress/* |