Skip to content

Commit

Permalink
re: extract release job into separate workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cybardev committed Mar 13, 2024
1 parent 0fe9ac1 commit a8c4a0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 85 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,4 @@ jobs:

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-*
uses: ./.github/workflows/release.yml
81 changes: 11 additions & 70 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,33 @@
# 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
name: Release

on:
push:
tags: ["v*"]

# Allows running this workflow from GitHub Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow releases
permissions:
contents: write
# Allows running this workflow from other workflows
workflow_call:
inputs:
tagged:
default: false
required: false
type: boolean

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

build:
needs: test
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 }}*
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download binaries
uses: actions/download-artifact@v2
with:
path: |
bin/
- name: Create Release
- name: Create Release with pushed tag
if: ${{ inputs.tagged }}
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
bin/ytgo-*/ytgo-*
- name: Create Release with latest tag
if: ${{ ! inputs.tagged }}
uses: "marvinpinto/action-automatic-releases@latest"
with:
automatic_release_tag: latest
Expand Down

0 comments on commit a8c4a0a

Please sign in to comment.