Skip to content

Commit

Permalink
change dev workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 14, 2023
1 parent 6a0d16e commit 8eadd83
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 84 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/_shared-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

name: Reusable build workflow
on:
workflow_call:

# shared build jobs
jobs:
build_linux_binary:
name: Build Linux binary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# setup global dependencies
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# setup project dependencies
- name: Get dependencies
run: |
go get -v -t -d ./...
# build binaries
- name: Build linux binary
run: |
make linux
# upload artifacts
- name: "Upload artifact: explorer_linux_amd64"
uses: actions/upload-artifact@v3
with:
path: ./bin/explorer_linux_amd64
name: explorer_linux_amd64

build_windows_binary:
name: Build Windows binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v3

# setup global dependencies
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# setup project dependencies
- name: Get dependencies
run: |
go get -v -t -d ./...
# build binaries
- name: Build windows binary
run: |
make windows
# upload artifacts
- name: "Upload artifact: explorer_windows_amd64.exe"
uses: actions/upload-artifact@v3
with:
path: ./bin/explorer_windows_amd64.exe
name: explorer_windows_amd64.exe

build_darwin_binary:
name: Build MacOS binary
runs-on: macos-latest
steps:
- uses: actions/checkout@v3

# setup global dependencies
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x

# setup project dependencies
- name: Get dependencies
run: |
go get -v -t -d ./...
# build binaries
- name: Build macos binary
run: |
make darwin
# upload artifacts
- name: "Upload artifact: explorer_darwin_amd64"
uses: actions/upload-artifact@v3
with:
path: ./bin/explorer_darwin_amd64
name: explorer_darwin_amd64
39 changes: 2 additions & 37 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,7 @@ on:
workflow_dispatch:

jobs:

build_binaries:
name: Build Binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# setup global dependencies
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x

# setup project dependencies
- name: Get dependencies
run: |
go get -v -t -d ./...
# build binaries
- run: |
make build
# upload artifacts
- name: "Upload artifact: explorer_windows_amd64.exe"
uses: actions/upload-artifact@v3
with:
path: ./bin/explorer_windows_amd64.exe
name: explorer_windows_amd64.exe
- name: "Upload artifact: explorer_linux_amd64"
uses: actions/upload-artifact@v3
with:
path: ./bin/explorer_linux_amd64
name: explorer_linux_amd64
- name: "Upload artifact: explorer_darwin_amd64"
uses: actions/upload-artifact@v3
with:
path: ./bin/explorer_darwin_amd64
name: explorer_darwin_amd64
name: "Build binaries"
uses: ./.github/workflows/_shared-build.yaml

38 changes: 15 additions & 23 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,17 @@ concurrency:
jobs:

build_binaries:
name: Build Binaries
name: "Build binaries"
uses: ./.github/workflows/_shared-build.yaml

create_snapshot_release:
name: Create snapshot release
needs: [build_binaries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# setup global dependencies
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x

# setup project dependencies
- name: Get dependencies
run: |
go get -v -t -d ./...
# build binaries
- run: |
make build
# download build artifacts
- name: "Download build artifacts"
uses: actions/download-artifact@v3

# (re)create snapshot binary release
- name: Update snapshot tag & remove previous snapshot release
Expand Down Expand Up @@ -106,29 +98,29 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}

# upload release artifacts
- name: "Upload artifact: explorer_windows_amd64.exe"
- name: "Upload snapshot release artifact: explorer_windows_amd64.exe"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/explorer_windows_amd64.exe
asset_path: ./explorer_windows_amd64.exe/explorer_windows_amd64.exe
asset_name: explorer_windows_amd64.exe
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: explorer_linux_amd64"
- name: "Upload snapshot release artifact: explorer_linux_amd64"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/explorer_linux_amd64
asset_path: ./explorer_linux_amd64/explorer_linux_amd64
asset_name: explorer_linux_amd64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: explorer_darwin_amd64"
- name: "Upload snapshot release artifact: explorer_darwin_amd64"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/explorer_darwin_amd64
asset_path: ./explorer_darwin_amd64/explorer_darwin_amd64
asset_name: explorer_darwin_amd64
asset_content_type: application/octet-stream
env:
Expand Down
33 changes: 12 additions & 21 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,19 @@ on:
description: "Version Number ('0.x.y')"
required: true


jobs:
build_binaries:
name: Build Binaries
name: "Build binaries"
uses: ./.github/workflows/_shared-build.yaml

create_release:
name: Create Release
needs: [build_binaries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# setup global dependencies
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x

# setup project dependencies
- name: Get dependencies
run: |
go get -v -t -d ./...
# build binaries
- run: |
make build
# download build artifacts
- name: "Download build artifacts"
uses: actions/download-artifact@v3

# create draft release
- name: Create latest release
Expand Down Expand Up @@ -58,7 +49,7 @@ jobs:
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/explorer_windows_amd64.exe
asset_path: ./explorer_windows_amd64.exe/explorer_windows_amd64.exe
asset_name: explorer_windows_amd64.exe
asset_content_type: application/octet-stream
env:
Expand All @@ -67,7 +58,7 @@ jobs:
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/explorer_linux_amd64
asset_path: ./explorer_linux_amd64/explorer_linux_amd64
asset_name: explorer_linux_amd64
asset_content_type: application/octet-stream
env:
Expand All @@ -76,7 +67,7 @@ jobs:
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin/explorer_darwin_amd64
asset_path: ./explorer_darwin_amd64/explorer_darwin_amd64
asset_name: explorer_darwin_amd64
asset_content_type: application/gzip
env:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ linux: $(LINUX)
darwin: $(DARWIN)

$(WINDOWS):
env GOOS=windows GOARCH=amd64 go build -v -o bin/$(WINDOWS) -ldflags="-s -w $(GOLDFLAGS)" ./cmd/explorer
env CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -v -o bin/$(WINDOWS) -ldflags="-s -w $(GOLDFLAGS)" ./cmd/explorer

$(LINUX):
env GOOS=linux GOARCH=amd64 go build -v -o bin/$(LINUX) -ldflags="-s -w $(GOLDFLAGS)" ./cmd/explorer
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -v -o bin/$(LINUX) -ldflags="-s -w $(GOLDFLAGS)" ./cmd/explorer

$(DARWIN):
env GOOS=darwin GOARCH=amd64 go build -v -o bin/$(DARWIN) -ldflags="-s -w $(GOLDFLAGS)" ./cmd/explorer
env CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -v -o bin/$(DARWIN) -ldflags="-s -w $(GOLDFLAGS)" ./cmd/explorer

clean:
rm -f $(WINDOWS) $(LINUX) $(DARWIN)

0 comments on commit 8eadd83

Please sign in to comment.