-
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.
feat: composite workflow to create latest release
- Loading branch information
Showing
3 changed files
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,36 @@ | ||
name: Build | ||
|
||
on: | ||
# Allows running this workflow from other workflows | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
os: [linux, darwin, windows] | ||
arch: [amd64, arm64] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.22" | ||
|
||
- name: Build for ${{ matrix.os }} (${{ matrix.arch }}) | ||
env: | ||
GOOS: ${{ matrix.os }} | ||
GOARCH: ${{ matrix.arch }} | ||
run: | | ||
[ "$GOOS" = "windows" ] && EXT=".exe" || EXT="" | ||
go build -C cmd/ytgo -o "../../bin/ytgo-${GOOS}-${GOARCH}${EXT}" | ||
- name: Upload ${{ matrix.os }}-${{ matrix.arch }} binary | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ytgo-${{ matrix.os }}-${{ matrix.arch }} | ||
path: | | ||
bin/ytgo-${{ matrix.os }}-${{ matrix.arch }}* |
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 @@ | ||
# This workflow will build a golang project and create a release with generated binaries | ||
|
||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | ||
|
||
name: CI/CD (latest) | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
# Allows running this workflow from other workflows | ||
workflow_call: | ||
|
||
# Allows running this workflow from GitHub Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
|
||
build: | ||
needs: test | ||
uses: ./.github/workflows/build.yml | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download binaries | ||
uses: actions/download-artifact@v2 | ||
with: | ||
path: | | ||
bin/ | ||
- name: Create Release with latest tag | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
automatic_release_tag: latest | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
prerelease: false | ||
files: | | ||
bin/ytgo-*/ytgo-* |
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,29 @@ | ||
name: Run Tests | ||
|
||
on: | ||
# Allows running this workflow from other workflows | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.22" | ||
|
||
- name: Test build | ||
run: go build -C cmd/ytgo -o "../../bin/ytgo" | ||
|
||
- name: Run tests | ||
run: go test -v -coverprofile=coverage.out ./cmd/ytgo | ||
|
||
- name: Report Coverage | ||
uses: shogo82148/actions-goveralls@v1 | ||
with: | ||
github-token: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
path-to-profile: coverage.out |