Skip to content
Merged
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
30 changes: 12 additions & 18 deletions .github/workflows/package-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ jobs:
with:
node-version: 22
cache: "npm"
- run: nix develop -c forge soldeer install
- name: Install soldeer dependencies
run: nix develop github:rainlanguage/rainix#sol-shell -c forge soldeer install
- name: Test JS/TS bindings
run: nix develop -c test-js-bindings
- name: Cargo test
run: nix develop -c cargo test -p rain-math-float
run: nix develop github:rainlanguage/rainix#rust-shell -c cargo test -p rain-math-float
- name: Git Config
run: |
git config --global user.email "${{ secrets.CI_GIT_EMAIL }}"
git config --global user.name "${{ secrets.CI_GIT_USER }}"
# NPM hash detection
- name: NPM hashes
id: npm
run: |
Expand All @@ -50,11 +50,10 @@ jobs:
echo "old=$OLD" >> $GITHUB_OUTPUT
echo "new=$NEW" >> $GITHUB_OUTPUT
if [ "$OLD" = "$NEW" ]; then echo "changed=false" >> $GITHUB_OUTPUT; else echo "changed=true" >> $GITHUB_OUTPUT; fi
# Cargo hash detection
- name: Cargo hashes
id: cargo
run: |
NEW=$(nix develop -c cargo package -p rain-math-float --allow-dirty --quiet --list | LC_ALL=C sort | sha256sum | cut -d' ' -f1)
NEW=$(nix develop github:rainlanguage/rainix#rust-shell -c cargo package -p rain-math-float --allow-dirty --quiet --list | LC_ALL=C sort | sha256sum | cut -d' ' -f1)
OLD_VERSION=$(curl -fsSL "https://crates.io/api/v1/crates/rain-math-float" | python3 -c "import sys, json; print(json.load(sys.stdin)['crate']['max_version'])" 2>/dev/null || echo "none")
if [ "$OLD_VERSION" = "none" ]; then
OLD="none"
Expand All @@ -65,14 +64,11 @@ jobs:
echo "old=$OLD" >> $GITHUB_OUTPUT
echo "new=$NEW" >> $GITHUB_OUTPUT
if [ "$OLD" = "$NEW" ]; then echo "changed=false" >> $GITHUB_OUTPUT; else echo "changed=true" >> $GITHUB_OUTPUT; fi
# Cargo first — cargo-release refuses to run if the working tree is
# dirty, and it makes its own commit.
- name: Bump Cargo version
if: ${{ steps.cargo.outputs.changed == 'true' }}
run: |
nix develop -c cargo release --no-confirm --execute --no-tag --no-push --no-publish -p rain-math-float patch
echo "CARGO_VERSION=v$(cargo pkgid -p rain-math-float | cut -d@ -f2)" >> $GITHUB_ENV
# NPM second — npm version edits files but doesn't commit.
nix develop github:rainlanguage/rainix#rust-shell -c cargo release --no-confirm --execute --no-tag --no-push --no-publish -p rain-math-float patch
echo "CARGO_VERSION=v$(nix develop github:rainlanguage/rainix#rust-shell -c cargo pkgid -p rain-math-float | cut -d@ -f2)" >> $GITHUB_ENV
- name: Bump NPM version
if: ${{ steps.npm.outputs.changed == 'true' }}
run: |
Expand All @@ -87,25 +83,23 @@ jobs:
if [ -n "${{ env.CARGO_VERSION }}" ]; then git tag crate-${{ env.CARGO_VERSION }}; fi
git push origin main
git push origin --tags
# NPM publish
- name: NPM pack
if: ${{ steps.npm.outputs.changed == 'true' }}
run: |
TARBALL=$(npm pack --silent)
mv "$TARBALL" float_npm_package_${{ env.NPM_VERSION }}.tgz
- name: Publish to crates.io
if: ${{ steps.cargo.outputs.changed == 'true' }}
run: nix develop github:rainlanguage/rainix#rust-shell -c cargo publish -p rain-math-float
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish to NPM
if: ${{ steps.npm.outputs.changed == 'true' }}
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
token: ${{ secrets.NPM_PUBLISH_PRIVATE_TOKEN }}
access: public
package: float_npm_package_${{ env.NPM_VERSION }}.tgz
# Cargo publish
- name: Publish to crates.io
if: ${{ steps.cargo.outputs.changed == 'true' }}
run: nix develop -c cargo publish -p rain-math-float
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: GitHub Release (npm)
if: ${{ steps.npm.outputs.changed == 'true' }}
uses: softprops/action-gh-release@v2
Expand Down
69 changes: 26 additions & 43 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Flake for development workflows.";

inputs = {
rainix.url = "github:rainprotocol/rainix";
rainix.url = "github:rainlanguage/rainix";
flake-utils.url = "github:numtide/flake-utils";
};

Expand Down
Loading