Skip to content

Commit

Permalink
feat(ci) add ci to publish to crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
uhryniuk committed Oct 13, 2024
1 parent 0fcc25e commit fe505f4
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 13 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/cargo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
on:
push:
tags:
- '*'
workflow_dispatch:

name: publish cargo

jobs:
audit:
name: Audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: rustsec/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

build_and_test_linux:
name: Build and Test (Linux)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- uses: taiki-e/install-action@nextest
- name: 'Build and test'
run: cargo nextest run --workspace --all-targets --all-features


build_and_test_macos:
name: Build and Test (MacOS)
runs-on: macos-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- uses: taiki-e/install-action@nextest
- name: 'Build and test'
run: cargo nextest run --workspace --all-targets --all-features

crates_io_publish:
name: Publish (crates.io)
needs:
- audit
- build_and_test_linux
- build_and_test_macos

runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: cargo-release Cache
id: cargo_release_cache
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-release
key: ${{ runner.os }}-cargo-release

- run: cargo install cargo-release
if: steps.cargo_release_cache.outputs.cache-hit != 'true'

- name: cargo login
run: cargo login ${{ secrets.CARGO_API_TOKEN }}

- name: "cargo release publish"
run: |-
cargo release \
publish \
--workspace \
--all-features \
--allow-branch main \
--no-confirm \
--execute
16 changes: 3 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: auto-release

on:
schedule:
- cron: '0 0 */14 * *' # Runs every 14 days at midnight UTC
workflow_dispatch:
# NOTE: Depcrated pipeline, here for reference
name: multi-build

jobs:
create-tag-release:
runs-on: ${{ matrix.runner }}

# Define the build matrix for cross-compilation
strategy:
matrix:
include:
Expand Down Expand Up @@ -62,30 +57,25 @@ jobs:
BIN_SUFFIX=".exe"
fi
# The built binary output location
BIN_OUTPUT="target/${{ matrix.target }}/release/${PROJECT_NAME}${BIN_SUFFIX}"

# Define a better name for the final binary
BIN_RELEASE="${PROJECT_NAME}-${{ matrix.name }}${BIN_SUFFIX}"
BIN_RELEASE_VERSIONED="${PROJECT_NAME}-${{ github.ref_name }}-${{ matrix.name }}${BIN_SUFFIX}"

# Move the built binary where you want it
# mv "${BIN_OUTPUT}" "./<your-destination>/${BIN_RELEASE}"
mv "${BIN_OUTPUT}" "./<your-destination>/${BIN_RELEASE}"

- name: Compress artifacts
run: |
mkdir -p artifacts
tar -czvf artifacts/${{ matrix.target }}-build_artifacts.tar.gz -C target/${{ matrix.target }}/release .
# Step 7: Create the new tag
- name: Create new tag
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git tag ${{ env.NEW_VERSION }}
git push origin ${{ env.NEW_VERSION }}
# Step 8: Upload the release artifacts for this architecture
- name: Create GitHub Release and Upload Artifacts
uses: actions/create-release@v1
env:
Expand Down

0 comments on commit fe505f4

Please sign in to comment.