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 8f1ef9f
Showing 1 changed file with 68 additions and 17 deletions.
85 changes: 68 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,62 @@ 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:
if: contains(github.ref, 'tags/v')
needs: [test, release]
permissions: write-all
name: Publish Binaries

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: 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: go build -o ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.version }}

- 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: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.version }}
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.version }}
asset_content_type: application/octet-stream

0 comments on commit 8f1ef9f

Please sign in to comment.