From 8eadd8381065745f77e8b70af2ed4f106793bf91 Mon Sep 17 00:00:00 2001 From: pk910 Date: Mon, 14 Aug 2023 23:51:59 +0200 Subject: [PATCH] change dev workflow --- .github/workflows/_shared-build.yaml | 93 ++++++++++++++++++++++++++++ .github/workflows/build-dev.yml | 39 +----------- .github/workflows/build-latest.yml | 38 +++++------- .github/workflows/build-release.yml | 33 ++++------ Makefile | 6 +- 5 files changed, 125 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/_shared-build.yaml diff --git a/.github/workflows/_shared-build.yaml b/.github/workflows/_shared-build.yaml new file mode 100644 index 00000000..f4e4d672 --- /dev/null +++ b/.github/workflows/_shared-build.yaml @@ -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 diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 0c6d628d..8f0e435e 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -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 diff --git a/.github/workflows/build-latest.yml b/.github/workflows/build-latest.yml index 6d5c4641..f5f95ff8 100644 --- a/.github/workflows/build-latest.yml +++ b/.github/workflows/build-latest.yml @@ -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 @@ -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: diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 4f3ef4db..12f199b2 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -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 @@ -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: @@ -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: @@ -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: diff --git a/Makefile b/Makefile index f3855b9b..6b010e93 100644 --- a/Makefile +++ b/Makefile @@ -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)