forked from Lightprotocol/light-protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Workflows for TypeScript and Rust project releases
* `release-ts-pr` - dispatch workflow for creating pull requests with version bumps. * `release-ts` - workflow which releases the projects on npmjs.org. Other changes: * Stop using `cargo-bins/release-pr` action. It's a bunch of cryptic TS code which is hard to debug when it doesn't work (they don't even have vebose logging). It's better to just call `cargo release` manually for bumping versions. `peter-evans/create-pull-request@v6` can be used to make the pull request. * Update the `tag` job to the current structure of the monorepo. That includes also Rust crates which were not up-to-date. * Simplify artifact handling in `release-rust` * Add missing fields in `Cargo.toml`, which are nowadays required by `cargo release` and `cargo pubish`
- Loading branch information
1 parent
041048a
commit 0ca438d
Showing
26 changed files
with
283 additions
and
151 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Open a TypeScript release PR | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
package: | ||
description: Package to release | ||
required: true | ||
type: choice | ||
options: | ||
- circuit-lib.js | ||
- cli | ||
- compressed-token | ||
- prover.js | ||
- stateless.js | ||
version: | ||
description: Version to release | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
bump-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Determine the subdirectory | ||
id: subdir | ||
run: | | ||
PROJECT_NAME="${{ inputs.package }}" | ||
if [[ "$PROJECT_NAME" == *"circuit-lib.js"* ]]; then | ||
SUBDIR="circuit-lib/circuit-lib.js" | ||
elif [[ "$PROJECT_NAME" == *"cli"* ]]; then | ||
SUBDIR="cli" | ||
elif [[ "$PROJECT_NAME" == *"compressed-token"* ]]; then | ||
SUBDIR="js/compressed-token" | ||
elif [[ "$PROJECT_NAME" == *"prover.js"* ]]; then | ||
SUBDIR="prover.js" | ||
elif [[ "$PROJECT_NAME" == *"stateless.js"* ]]; then | ||
SUBDIR="js/stateless.js" | ||
fi | ||
echo "subdir='$SUBDIR'" >> "$GITHUB_OUTPUT" | ||
- name: Bump package version | ||
run: | | ||
cd ${{ steps.subdir.outputs.subdir }} | ||
pnpm version ${{ inputs.version }} | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v6 | ||
env: | ||
COMMIT_MESSAGE: "chore: bump version of ${{ inputs.package }} to ${{ inputs.version }}" | ||
with: | ||
commit-message: ${{ env.COMMIT_MESSAGE }} | ||
title: ${{ env.COMMIT_MESSAGE }} | ||
branch: "bump-${{ inputs.package }}-to-${{ inputs.version }}" | ||
labels: "version bump" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,132 @@ | ||
name: Release programs | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
permissions: | ||
contents: write | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
auto-tag: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Setup and build | ||
uses: ./.github/actions/setup-and-build | ||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: 8 | ||
run_install: false | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
|
||
- name: Extract version | ||
id: version | ||
shell: bash | ||
run: | | ||
set -eux | ||
function rust_version() { | ||
cargo pkgid -p $1 | cut -d "@" -f2 | ||
} | ||
function ts_version() { | ||
pnpm list --filter $1 --depth 0 --json | jq -r '.[0].version' | ||
} | ||
COMMIT_MESSAGE=$(git log -1 --pretty=format:'%s') | ||
PACKAGE="" | ||
VERSION="" | ||
LANGUAGE="" | ||
if [[ "$COMMIT_MESSAGE" == *"bump version of"* ]]; then | ||
PACKAGE=$(echo "$COMMIT_MESSAGE" | grep -o "bump version of [^ ]*" | cut -d " " -f4) | ||
if [[ -n "$PACKAGE_NAME" ]]; then | ||
# First try getting the Rust version. | ||
VERSION=$(rust_version "$PACKAGE_NAME") | ||
LANGUAGE="rust" | ||
if [[ -z "$VERSION" ]]; then | ||
# If no version was found, try the TypeScript version. | ||
VERSION=$(ts_version "$PACKAGE_NAME") | ||
LANGUAGE="ts" | ||
fi | ||
fi | ||
if [[ -z "$VERSION" ]] || [[ -z "$LANGUAGE" ]]; then | ||
echo "Could not detect the version ($VERSION) or language ($LANGUAGE) of project $PROJECT" | ||
fi | ||
fi | ||
echo "package=$PACKAGE" >> "$GITHUB_OUTPUT" | ||
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
echo "language=$LANGUAGE" >> "$GITHUB_OUTPUT" | ||
- name: Extract crate name from tag | ||
id: extract-crate | ||
- name: Tag | ||
id: tag | ||
if: ${{ steps.version.outputs.version }} | ||
env: | ||
VERSION: ${{ steps.version.outputs.version }} | ||
run: | | ||
TAG_NAME="${GITHUB_REF#refs/tags/}" | ||
CRATE_NAME="$(echo "$TAG_NAME" | rev | cut -d'-' -f2- | rev)" | ||
echo "Creating tag for package: $PACKAGE_NAME v$VERSION" | ||
if [[ "$CRATE_NAME" == *"account-compression"* ]]; then | ||
NEW_TAG="v$VERSION" | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
git tag "${PACKAGE_NAME}-${NEW_TAG}" | ||
git push origin "${PACKAGE_NAME}-${NEW_TAG}" | ||
- name: Release Rust | ||
if: ${{ steps.version.outputs.language }} == "rust" | ||
shell: bash | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | ||
PACKAGE: ${{ steps.version.outputs.package }} | ||
run: | | ||
# Check whether we are building an on-chain program. If yes, prepare | ||
# an artifact. | ||
ARTIFACT="" | ||
if [[ "$ARTIFACT" == *"account-compression"* ]]; then | ||
ARTIFACT="account_compression.so" | ||
elif [[ "$CRATE_NAME" == *"light-compressed-pda"* ]]; then | ||
elif [[ "$ARTIFACT" == *"light-compressed-pda"* ]]; then | ||
ARTIFACT="light_compressed_pda.so" | ||
elif [[ "$CRATE_NAME" == *"light-compressed-token"* ]]; then | ||
elif [[ "$ARTIFACT" == *"light-compressed-token"* ]]; then | ||
ARTIFACT="light_compressed_token.so" | ||
elif [[ "$CRATE_NAME" == *"light-user-registry"* ]]; then | ||
elif [[ "$ARTIFACT" == *"light-user-registry"* ]]; then | ||
ARTIFACT="light_user_registry.so" | ||
elif [[ "$CRATE_NAME" == *"light-registry"* ]]; then | ||
elif [[ "$ARTIFACT" == *"light-registry"* ]]; then | ||
ARTIFACT="light_registry.so" | ||
fi | ||
echo "crate=$CRATE_NAME" >> "$GITHUB_OUTPUT" | ||
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT" | ||
if [[ -n "$ARTIFACT" ]]; then | ||
anchor build -p "$PACKAGE" | ||
fi | ||
- name: Prepare artifacts | ||
cargo publish \ | ||
-p "${{ steps.extract-crate.outputs.crate }}" \ | ||
--token "$CARGO_REGISTRY_TOKEN" | ||
- name: Release TypeScript | ||
if: ${{ steps.version.outputs.language }} == "ts" | ||
shell: bash | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | ||
NPM_CONFIG_PROVENANCE: true | ||
PACKAGE: ${{ steps.version.outputs.package }} | ||
run: | | ||
if [[ "$CRATE_NAME" == *"account-compression"* ]]; then | ||
cp target/deploy/account_compression.so . | ||
elif [[ "$CRATE_NAME" == *"light-compressed-pda"* ]]; then | ||
cp target/deploy/light_compressed_pda.so . | ||
elif [[ "$CRATE_NAME" == *"light-compressed-token"* ]]; then | ||
cp target/deploy/light_compressed_token.so . | ||
elif [[ "$CRATE_NAME" == *"light-user-registry"* ]]; then | ||
cp target/deploy/light_user_registry.so . | ||
elif [[ "$CRATE_NAME" == *"light-registry"* ]]; then | ||
cp target/deploy/light_registry.so . | ||
fi | ||
SUBDIR=$(grep "$PACKAGE" pnpm-workspace.yaml | awk -F '"' '{gsub("/\\*\\*", "", $2); print $2}') | ||
cd "$SUBDIR" | ||
pnpm publish --access public --no-git-checks | ||
- name: Release | ||
- name: GitHub release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
token: ${{ secrets.PAT_TOKEN }} | ||
files: | | ||
"${{ steps.extract-crate.outputs.artifact }}" | ||
- name: Run cargo publish | ||
# Skip macro-circom, it has a git dependency preventing it from publishing. | ||
if: steps.extract-crate.outputs.crate != 'macro-circom' | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | ||
run: | | ||
cargo publish -p "${{ steps.extract-crate.outputs.crate }}" --token "$CARGO_REGISTRY_TOKEN" |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.