chore: prepare release (#8) #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
prerelease: | |
description: Check the box to create a pre-release | |
type: boolean | |
required: false | |
default: true | |
push: | |
branches: | |
- main | |
paths: | |
- bar/Cargo.toml | |
- cli/Cargo.toml | |
jobs: | |
prerelease-status: | |
name: Check if this is a pre-release | |
runs-on: ubuntu-latest | |
outputs: | |
KNOPE_PRERELEASE_LABEL: ${{ env.KNOPE_PRERELEASE_LABEL }} | |
steps: | |
- name: Check if this is a pre-release | |
id: prerelease | |
if: ${{ github.event.inputs.prerelease == 'true' }} || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' | |
run: | | |
echo "KNOPE_PRERELEASE_LABEL=nigthly" >> "$GITHUB_ENV" | |
shell: bash | |
build: | |
needs: prerelease-status | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
target: x86_64-unknown-linux-gnu | |
code-target: linux-x64 | |
- os: macos-14 | |
target: aarch64-apple-darwin | |
code-target: darwin-arm64 | |
name: Package ${{ matrix.code-target }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install Node.js | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
node-version: 20 | |
- name: Install toolchain | |
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1.2.1 | |
with: | |
channel: stable | |
cache-target: release | |
cache-base: main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Audit crates.io dependencies | |
if: matrix.code-target == 'linux-x64' | |
run: cargo audit | |
- name: Set jemalloc page size for linux-arm64 | |
if: matrix.code-target == 'linux-arm64' | |
run: | | |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV | |
# Build the CLI binary | |
- name: Build binaries | |
run: cargo build -p cli --release --target ${{ matrix.target }} | |
env: | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc | |
# Strip all debug symbols from the resulting binaries | |
RUSTFLAGS: "-C strip=symbols -C codegen-units=1" | |
# Copy the CLI binary and rename it to include the name of the target platform | |
- name: Copy CLI binary | |
if: matrix.os == 'windows-2022' | |
run: | | |
mkdir dist | |
cp target/${{ matrix.target }}/release/cli.exe ./dist/cli-${{ matrix.code-target }}.exe | |
- name: Copy CLI binary | |
if: matrix.os != 'windows-2022' | |
run: | | |
mkdir dist | |
cp target/${{ matrix.target }}/release/cli ./dist/cli-${{ matrix.code-target }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: cli-${{ matrix.target }} | |
path: ./dist/cli-* | |
if-no-files-found: error | |
release: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
environment: npm-publish | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Download CLI artifacts | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
pattern: cli-* | |
merge-multiple: true | |
- uses: knope-dev/action@407e9ef7c272d2dd53a4e71e39a7839e29933c48 # v2.1.0 | |
with: | |
version: 0.18.0 | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- run: knope release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-npm: | |
name: Publish npm packages | |
runs-on: ubuntu-latest | |
needs: release | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Download CLI artifacts | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
pattern: cli-* | |
merge-multiple: true | |
- name: "Fake Publish" | |
run: echo "Fake Publish CLI" | |
publish-crates: | |
name: Publish crates | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Install toolchain | |
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1.2.1 | |
with: | |
channel: stable | |
cache-target: release | |
cache-base: main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: katyo/publish-crates@v2 | |
with: | |
no-verify: true | |
dry-run: true | |
check-repo: true |