Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Publish
on:
workflow_dispatch:
inputs:
release_version:
description: "Version of this release"
required: true
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, clippy

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: update version
run: |
export VERSION=${{ github.event.inputs.release_version }}
sed -i "s/0.0.0/$VERSION/g" Cargo.toml

- name: Tag 🏷️
uses: actions/github-script@v5
id: create-tag
with:
github-token: ${{secrets.TODO}}
script: |
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ github.event.inputs.release_version }}',
sha: context.sha
})

- name: Build
run: make build

- name: Run tests
run: make test

- name: Run linter
run: make lint

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

# allow-branch HEAD is because GitHub actions switches
# to the tag while building, which is a detached head

# Publishing is currently messy, because:
#
# * `peace_rt_model_core` exports `NativeError` or `WebError` depending on the target.
# * `peace_rt_model_web` fails to build when publishing the workspace for a native target.
# * `peace_rt_model_web` still needs its dependencies to be published before it can be
# published.
# * `peace_rt_model_hack` needs `peace_rt_model_web` to be published before it can be
# published.
#
# We *could* pass through `--no-verify` so `cargo` doesn't build the crate before publishing,
# which is reasonable, since this job only runs after the Linux, Windows, and WASM builds
# have passed.
- name: "cargo publish"
run: |
cargo publish --locked --package recall_provider
cargo publish --locked --package recall_signer
cargo publish --locked --package recall_sdk

- name: Version 👍
id: version-bump
uses: jaywcjlove/github-action-package@v1.3.0
with:
version: ${{ github.event.inputs.release_version }}

- name: Install 🔧
run: npm install

- name: Conditional ✅
id: cond
uses: haya14busa/action-cond@v1
with:
cond: ${{ contains(github.event.inputs.release_version, '-') }}
if_true: "next"
if_false: "latest"

- name: Publish 📦
id: publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_AUTH_TOKEN }}
tag: ${{ steps.cond.outputs.value }}
access: public
check-version: true

- name: Release 🚀
if: steps.publish.outputs.type != 'none'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.publish.outputs.version }}
generateReleaseNotes: true
prerelease: ${{ contains(steps.publish.outputs.type, 'pre') }}
token: ${{ secrets.GITHUB_TOKEN }}
Loading
Loading