-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add build workflow * fix env set * fix syntax * ignore windows build for now.
- Loading branch information
1 parent
63ee9e6
commit cc9ba35
Showing
1 changed file
with
106 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,106 @@ | ||
name: Build | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up environment | ||
run: echo "VERSION_NUMBER=${GITHUB_REF:10}" >> ${GITHUB_ENV} | ||
|
||
- name: Set up Go 1.14 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.14 | ||
|
||
- name: Download dependencies | ||
run: go mod download | ||
|
||
- name: Build | ||
run: | | ||
go build -v . | ||
chmod +x gg | ||
mkdir pub | ||
cp gg pub | ||
- name: Test | ||
env: | ||
TEST_TOKEN: ${{ secrets.TEST_TOKEN }} | ||
run: | | ||
export PATH="${PATH}:`pwd`" | ||
# Login | ||
gg sync --token ${TEST_TOKEN} | ||
# Remove old gists | ||
gg rm `gg ls | cut -f 1 | tail +3` | ||
bash tests/functional-tests.sh | ||
- name: Install gox | ||
run: go install github.com/mitchellh/gox | ||
|
||
- name: Build | ||
run: | | ||
$HOME/go/bin/gox -ldflags "-X main.Version=$VERSION_NUMBER" \ | ||
--output="$GOX_OUTPUT" \ | ||
--osarch="$GOX_OSARCH" \ | ||
github.com/$GITHUB_REPOSITORY | ||
env: | ||
GOX_OUTPUT: "./{{.Dir}}_{{.OS}}" | ||
GOX_OSARCH: "linux/amd64 darwin/amd64" | ||
|
||
- name: Move Darwin | ||
run: mv gg_darwin gg_macos | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: gg_macos | ||
path: gg_macos | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
if: contains(github.ref, 'tags/v') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: true | ||
prerelease: false | ||
|
||
- name: Upload MACOS binary | ||
uses: actions/[email protected] | ||
if: contains(github.ref, 'tags/v') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: gg_macos | ||
asset_name: gg_macos | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload Linux Binary | ||
uses: actions/[email protected] | ||
if: contains(github.ref, 'tags/v') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: gg_linux | ||
asset_name: gg_linux | ||
asset_content_type: application/octet-stream | ||
|
||
# - name: Upload Windows Binary | ||
# uses: actions/[email protected] | ||
# if: contains(github.ref, 'tags/v') | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
# asset_path: gg_windows.exe | ||
# asset_name: gg_windows.exe | ||
# asset_content_type: application/octet-stream |