Skip to content
Merged
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
116 changes: 5 additions & 111 deletions .github/workflows/package-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,114 +5,8 @@ on:
- main
jobs:
release:
if: ${{ github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'Package Release') }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.PUBLISH_PRIVATE_KEY }}
fetch-depth: 0
- uses: nixbuild/nix-quick-install-action@v30
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-
gc-max-store-size-linux: 1G
- name: Install soldeer dependencies
run: nix develop github:rainlanguage/rainix#sol-shell -c forge soldeer install
- name: Test JS/TS bindings
run: |
nix develop github:rainlanguage/rainix#rust-node-shell -c bash -c \
"npm install --no-check && npm run build && npm test"
- name: Cargo test
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 }}"
- name: NPM hashes
id: npm
run: |
nix develop github:rainlanguage/rainix#rust-node-shell -c bash -c '
OLD=$(npm view @rainlanguage/float@latest dist.shasum 2>/dev/null || echo "none")
NEW=$(npm pack --silent | xargs shasum | cut -c1-40)
rm -f *.tgz
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
'
- name: Cargo hashes
id: cargo
run: |
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"
else
curl -fsSL "https://crates.io/api/v1/crates/rain-math-float/$OLD_VERSION/download" -o /tmp/old.crate
OLD=$(tar -tzf /tmp/old.crate 2>/dev/null | LC_ALL=C sort | sha256sum | cut -d' ' -f1)
fi
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
- name: Bump Cargo version
if: ${{ steps.cargo.outputs.changed == 'true' }}
run: |
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: |
NEW=$(nix develop github:rainlanguage/rainix#rust-node-shell -c npm version patch --no-git-tag-version)
echo "NPM_VERSION=$NEW" >> $GITHUB_ENV
git add package.json package-lock.json
git commit -m "Package Release npm-${NEW}"
- name: Tag and push
if: ${{ steps.npm.outputs.changed == 'true' || steps.cargo.outputs.changed == 'true' }}
run: |
if [ -n "${{ env.NPM_VERSION }}" ]; then git tag npm-${{ env.NPM_VERSION }}; fi
if [ -n "${{ env.CARGO_VERSION }}" ]; then git tag crate-${{ env.CARGO_VERSION }}; fi
git push origin main
git push origin --tags
- name: NPM pack
if: ${{ steps.npm.outputs.changed == 'true' }}
run: |
TARBALL=$(nix develop github:rainlanguage/rainix#rust-node-shell -c 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_PUBLISH_PRIVATE_TOKEN }}
access: public
package: float_npm_package_${{ env.NPM_VERSION }}.tgz
- name: GitHub Release (npm)
if: ${{ steps.npm.outputs.changed == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: npm-${{ env.NPM_VERSION }}
name: NPM Package Release ${{ env.NPM_VERSION }}
files: float_npm_package_${{ env.NPM_VERSION }}.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: GitHub Release (cargo)
if: ${{ steps.cargo.outputs.changed == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: crate-${{ env.CARGO_VERSION }}
name: Cargo Crate Release crate-${{ env.CARGO_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: rainlanguage/rainix/.github/workflows/rainix-autopublish.yaml@main
with:
crate: rain-math-float
npm-package: "@rainlanguage/float"
secrets: inherit
Loading