Skip to content

Commit

Permalink
chore: multiple assets per release
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamacho-d committed Aug 9, 2023
1 parent 4106b4a commit 3a8032c
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 19 deletions.
194 changes: 177 additions & 17 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
name: Build Release
name: Build and Publish Release

on:
push:
tags:
- v**
workflow_dispatch:

jobs:
release-bin:
permissions: write-all
name: Create Release Binary

test:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
architecture: [x64, arm64]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set Up Go
- name: Setup Go Environment
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Run Tests
run: go test ./...

- name: Get Tag from Git Reference
release:
if: contains(github.ref, 'tags/v')
permissions: write-all
name: Create GitHub Release
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set Release Tag
id: get_tag
run: echo "::set-output name=tag::$(echo $GITHUB_REF | sed -n 's/refs\/tags\///p')"

- name: Build
run: go build -o pup-${{ steps.get_tag.outputs.tag }}-${{ matrix.os }}-${{ matrix.architecture }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -43,13 +45,171 @@ jobs:
release_name: Release ${{ steps.get_tag.outputs.tag }}
body: |
Describe your release here.
draft: true
prerelease: false
- name: Create Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for Publishing
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt

publish-linux:
if: contains(github.ref, 'tags/v')
needs: [test, release]
permissions: write-all
name: Publish Binaries (Ubuntu)
runs-on: ubuntu-latest

strategy:
matrix:
goos: [linux]
goarch: ["386", "amd64", "arm", "arm64"]

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Load Release URL File from Release Job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Get Tag from Git Reference
id: get_tag
run: echo "::set-output name=tag::$(echo $GITHUB_REF | sed -n 's/refs\/tags\///p')"
- name: Get Release File Name & Upload URL
id: get_release_info
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0
value=$(cat release_url/release_url.txt)
echo ::set-output name=upload_url::$value
- name: Setup Go Environment
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Build Binary
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }}
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }}
asset_content_type: application/octet-stream

publish-darwin:
if: contains(github.ref, 'tags/v')
needs: [test, release]
permissions: write-all
name: Publish Binaries (Mac OS)
runs-on: macos-latest

strategy:
matrix:
goos: [darwin]
goarch: ["amd64", "arm64"]

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Load Release URL File from Release Job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Get Tag from Git Reference
id: get_tag
run: echo "::set-output name=tag::$(echo $GITHUB_REF | sed -n 's/refs\/tags\///p')"
- name: Get Release File Name & Upload URL
id: get_release_info
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0
value=$(cat release_url/release_url.txt)
echo ::set-output name=upload_url::$value
- name: Setup Go Environment
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Build Binary
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }}

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }}
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }}
asset_content_type: application/octet-stream

publish-windows:
if: contains(github.ref, 'tags/v')
needs: [test, release]
permissions: write-all
name: Publish Binaries (Windows)
runs-on: windows-latest

strategy:
matrix:
goos: [windows]
goarch: ["386", "amd64"]

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Load Release URL File from Release Job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Get Tag from Git Reference
id: get_tag
run: echo "::set-output name=tag::$(echo $GITHUB_REF | sed -n 's/refs\/tags\///p')"

- name: Get Release File Name & Upload URL (windows)
id: get_release_info
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
run: |
$repoName = $env:REPOSITORY_NAME -replace ".*/", ""
$tagName = $env:TAG_REF_NAME -replace ".*/v", ""
$file_name = "${repoName}-${tagName}"
Write-Host "file_name=$file_name"
$value = Get-Content release_url/release_url.txt
Write-Host "upload_url=$value"
echo "file_name=$file_name" >> $env:GITHUB_ENV
echo "upload_url=$value" >> $env:GITHUB_ENV
- name: Setup Go Environment
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Build Binary
run: |
$env:GOOS="${{ matrix.goos }}"
$env:GOARCH="${{ matrix.goarch }}"
$file_name = $env:file_name + "-${{ matrix.goos }}-${{ matrix.goarch }}"
go build -o $file_name
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: pup-${{ steps.get_tag.outputs.tag }}-${{ matrix.os }}-${{ matrix.architecture }}
asset_name: pup-${{ steps.get_tag.outputs.tag }}-${{ matrix.os }}-${{ matrix.architecture }}
upload_url: ${{ env:upload_url }}
asset_path: $filename
asset_name: $filename
asset_content_type: application/octet-stream
2 changes: 1 addition & 1 deletion pup.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// |/ \_( # |"
// C/ ,--___/

var VERSION string = "0.4.0"
var VERSION string = "0.4.1"

func main() {
// process flags and arguments
Expand Down
2 changes: 1 addition & 1 deletion pup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'formula'
class Pup < Formula
homepage 'https://github.com/ccamacho-d/pup'
version '0.4.0'
version '0.4.1'

if Hardware::CPU.is_64_bit?
url 'https://github.com/ccamacho-d/pup/releases/download/v0.4.1/pup_v0.4.1_darwin_amd64.zip'
Expand Down

0 comments on commit 3a8032c

Please sign in to comment.