Add GitHub CI security and release workflows
This commit is contained in:
parent
9422cd0da4
commit
1006f41e45
10 changed files with 396 additions and 0 deletions
99
.github/workflows/release.yml
vendored
Normal file
99
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
prerelease:
|
||||
description: "Mark the GitHub release as a prerelease"
|
||||
required: false
|
||||
default: "true"
|
||||
type: choice
|
||||
options: ["true", "false"]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build ${{ matrix.target }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: linux-x86_64
|
||||
binary: geth
|
||||
- os: macos-latest
|
||||
target: macos
|
||||
binary: geth
|
||||
- os: windows-latest
|
||||
target: windows-x86_64
|
||||
binary: geth.exe
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Cache Cargo
|
||||
uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Build release binary
|
||||
run: cargo build --release -p geth
|
||||
|
||||
- name: Package Unix artifact
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version="${GITHUB_REF_NAME:-manual}"
|
||||
pkg="geth-${version}-${{ matrix.target }}"
|
||||
mkdir -p "${pkg}" dist
|
||||
cp "target/release/${{ matrix.binary }}" "${pkg}/"
|
||||
cp README.md "${pkg}/"
|
||||
tar -czf "dist/${pkg}.tar.gz" "${pkg}"
|
||||
|
||||
- name: Package Windows artifact
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$version = if ($env:GITHUB_REF_NAME) { $env:GITHUB_REF_NAME } else { "manual" }
|
||||
$pkg = "geth-$version-${{ matrix.target }}"
|
||||
New-Item -ItemType Directory -Force -Path $pkg, dist | Out-Null
|
||||
Copy-Item "target/release/${{ matrix.binary }}" "$pkg/"
|
||||
Copy-Item README.md "$pkg/"
|
||||
Compress-Archive -Path "$pkg/*" -DestinationPath "dist/$pkg.zip" -Force
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: geth-${{ matrix.target }}
|
||||
path: dist/*
|
||||
if-no-files-found: error
|
||||
|
||||
github-release:
|
||||
name: publish GitHub release
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: Publish release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: dist/*
|
||||
prerelease: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.prerelease == 'true' }}
|
||||
generate_release_notes: true
|
||||
Loading…
Reference in a new issue