-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): build, test, release + installer ready (#4)
- Loading branch information
Showing
5 changed files
with
166 additions
and
3 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,58 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
inputs: | ||
create_release: | ||
description: 'Check if workflows called from Github Release event.' | ||
default: false | ||
required: false | ||
type: boolean | ||
|
||
jobs: | ||
go-build: | ||
name: Run Go Build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: [1.21.x] | ||
goos: [linux, windows, darwin] | ||
goarch: [amd64] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
cache-dependency-path: "go.sum" | ||
- name: Build ${{ matrix.goos }}/${{ matrix.goarch }} | ||
id: build | ||
run: | | ||
output_name=world-cli_${{ matrix.goos }}_${{ matrix.goarch }} | ||
[ ${{ matrix.goos }} = "windows" ] && output_name+=".exe" | ||
env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o $output_name | ||
echo "output_name=$output_name" >> $GITHUB_OUTPUT | ||
- name: Compress Build Binary | ||
uses: a7ul/[email protected] | ||
id: compress | ||
with: | ||
command: c | ||
files: | | ||
./${{ steps.build.outputs.output_name }} | ||
outPath: ${{ steps.build.outputs.output_name }}.tar.gz | ||
- name: Upload binary to Github artifact | ||
if: ${{ inputs.create_release }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: world-cli-${{ matrix.goos }}-${{ matrix.goarch }} | ||
path: ./world-cli*.tar.gz |
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,36 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
go-test: | ||
name: Test | ||
uses: ./.github/workflows/test.yml | ||
|
||
go-build: | ||
name: Build | ||
uses: ./.github/workflows/build.yml | ||
with: | ||
create_release: true | ||
|
||
release: | ||
name: Release world-cli binary | ||
runs-on: ubuntu-latest | ||
needs: [go-test, go-build] | ||
strategy: | ||
matrix: | ||
go-version: [1.21.x] | ||
steps: | ||
- name: Download world-cli build binary | ||
uses: actions/download-artifact@v3 | ||
- name: Display downloaded files | ||
run: | | ||
ls -R | ||
- name: Publish world-cli binary to corresponding Github Release | ||
uses: skx/github-action-publish-binaries@master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
args: 'world-cli*/*.tar.gz' |
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,55 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
workflow_call: | ||
|
||
jobs: | ||
go-test: | ||
name: Run Go Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go-version: [1.21.x] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
cache-dependency-path: "go.sum" | ||
- name: Test | ||
run: | | ||
go test ./... -coverprofile=coverage.out -covermode=count -v | ||
- name: Upload coverage results to Github artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage | ||
path: ./coverage.out | ||
upload-codecov: | ||
name: Upload coverage output to Codecov.io | ||
runs-on: ubuntu-latest | ||
needs: go-test | ||
if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download coverage output file | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: coverage | ||
- name: Upload coverage output to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
with: | ||
fail_ci_if_error: true | ||
directory: "./" |
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
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