Skip to content

Commit

Permalink
Update publish action to build and publish binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
tjk committed Nov 22, 2024
1 parent 5918f65 commit 9e5612c
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: Publish

on:
workflow_dispatch:
push:
tags:
- v[0-9]+.*

permissions:
contents: write

jobs:
publish:
name: Publish to crates.io
name: Publish to crates.io and GitHub
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -24,6 +27,7 @@ jobs:
run: cargo test

- name: Check version matches tag
if: github.event_name == 'push'
run: |
PKG_VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
TAG_VERSION=${GITHUB_REF#refs/tags/v}
Expand All @@ -32,12 +36,58 @@ jobs:
exit 1
fi
- name: Build release binaries
run: |
cargo build --release
mkdir -p release-artifacts
cp target/release/termv release-artifacts/termv-${{ github.ref_name }}-linux-x86_64
- name: Publish to crates.io
if: github.event_name == 'push'
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

- name: Create GitHub Release
if: github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
files: |
release-artifacts/*
build-macos:
name: Build macOS binary
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
cargo build --release
mkdir -p release-artifacts
cp target/release/termv release-artifacts/termv-${{ github.ref_name }}-darwin-x86_64
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-binary
path: release-artifacts/*

build-windows:
name: Build Windows binary
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build release binary
run: |
cargo build --release
mkdir release-artifacts
copy target\release\termv.exe release-artifacts\termv-${{ github.ref_name }}-windows-x86_64.exe
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-binary
path: release-artifacts\*

0 comments on commit 9e5612c

Please sign in to comment.