Skip to content

Commit

Permalink
Refactor: Change build workflow to also publish a release
Browse files Browse the repository at this point in the history
  • Loading branch information
angelplusultra committed Dec 14, 2024
1 parent a3288a3 commit 1563f61
Showing 1 changed file with 72 additions and 5 deletions.
77 changes: 72 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Cross Build
name: Cross Build and Release

on:
# workflow_dispatch: # Enables manual triggering
workflow_dispatch: # Enables manual triggering
push:
tags:
- "v*" # Matches tags like v1.0.0, v2.3.4, etc.
- "v[0-9]+.[0-9]+.[0-9]+" # Matches tags like v1.0.0, v2.3.4, etc.

jobs:
build-windows:
runs-on: ubuntu-latest # Ubuntu runner for Linux and Windows builds
runs-on: ubuntu-latest

steps:
# Checkout the code
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
path: target/x86_64-pc-windows-gnu/release/jobshell.exe

build-macos:
runs-on: macos-latest # macOS runner for macOS builds
runs-on: macos-latest

steps:
# Checkout the code
Expand Down Expand Up @@ -82,3 +82,70 @@ jobs:
name: jobshell-macos-aarch64-binary
path: target/aarch64-apple-darwin/release/jobshell

release:
runs-on: ubuntu-latest
needs:
- build-windows
- build-macos

steps:
# Checkout the code
- name: Checkout repository
uses: actions/checkout@v3

# Download Windows artifact
- name: Download Windows artifact
uses: actions/download-artifact@v3
with:
name: windows-binary

# Download macOS artifacts
- name: Download macOS (x86_64) artifact
uses: actions/download-artifact@v3
with:
name: jobshell-macos-x86_64-binary

- name: Download macOS (aarch64) artifact
uses: actions/download-artifact@v3
with:
name: jobshell-macos-aarch64-binary

# Create GitHub Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref_name }} # Use the latest pushed tag
release_name: "Release ${{ github.ref_name }}"
body: |
### Changes in this Release
- Windows and macOS binaries included.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Upload Release Assets
- name: Upload Windows binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/x86_64-pc-windows-gnu/release/jobshell.exe
asset_name: jobshell-windows-x86_64.exe
asset_content_type: application/octet-stream

- name: Upload macOS (x86_64) binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/x86_64-apple-darwin/release/jobshell
asset_name: jobshell-macos-x86_64
asset_content_type: application/octet-stream

- name: Upload macOS (aarch64) binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/aarch64-apple-darwin/release/jobshell
asset_name: jobshell-macos-aarch64
asset_content_type: application/octet-stream

0 comments on commit 1563f61

Please sign in to comment.