fix(transaction): avoid eager reservation of nonce and stray pending tx #13
This file contains hidden or 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
| name: CI/CD | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - 'release/**' | |
| - 'master' | |
| pull_request: | |
| jobs: | |
| fmt: | |
| name: Rustfmt | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - run: rustup component add rustfmt | |
| - run: cargo fmt --all -- --check | |
| clippy: | |
| name: Clippy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - run: rustup component add clippy | |
| - run: cargo clippy -- -D warnings -A clippy::uninlined_format_args | |
| test: | |
| name: Test | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: true | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y libssl-dev pkg-config | |
| - name: Run tests | |
| run: cargo test --exclude rust-sdk-playground --workspace | |
| create_pr: | |
| name: Create Release PR | |
| runs-on: ubuntu-22.04 | |
| needs: test | |
| if: | | |
| github.actor != 'github-actions[bot]' && | |
| startsWith(github.ref, 'refs/heads/release/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Extract version from branch name | |
| run: | | |
| VERSION=${GITHUB_REF#refs/heads/release/} | |
| echo "VERSION_NAME=$VERSION" >> $GITHUB_ENV | |
| - name: Update Cargo.toml versions | |
| run: | | |
| sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' crates/cli/Cargo.toml | |
| sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' crates/core/Cargo.toml | |
| sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' crates/sdk/Cargo.toml | |
| sed -i 's/^version = ".*"/version = "${{ env.VERSION_NAME }}"/' Cargo.toml | |
| - name: Commit changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add crates/cli/Cargo.toml crates/core/Cargo.toml crates/sdk/Cargo.toml Cargo.toml | |
| git commit -m "Release v${{ env.VERSION_NAME }}" | |
| git push origin release/${{ env.VERSION_NAME }} | |
| - name: Check if PR already exists | |
| id: check_pr | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PR_EXISTS=$(gh pr list --base master --head release/${{ env.VERSION_NAME }} --json number --jq length) | |
| if [ "$PR_EXISTS" -gt 0 ]; then | |
| echo "pr_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "pr_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check_pr.outputs.pr_exists == 'false' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --title "Release v${{ env.VERSION_NAME }}" \ | |
| --body "## Release v${{ env.VERSION_NAME }} | |
| This PR contains: | |
| - Version bump to ${{ env.VERSION_NAME }} | |
| **Merging this PR will automatically create a GitHub Release and build Docker images.**" \ | |
| --base master \ | |
| --head release/${{ env.VERSION_NAME }} | |
| release: | |
| name: Create GitHub Release | |
| runs-on: ubuntu-22.04 | |
| needs: [fmt, clippy, test] | |
| if: | | |
| github.actor != 'github-actions[bot]' && | |
| github.ref == 'refs/heads/master' && | |
| github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if this is a release commit | |
| id: check_release | |
| run: | | |
| COMMIT_MSG=$(git log --oneline -1 --pretty=format:"%s") | |
| VERSION=$(echo "$COMMIT_MSG" | grep -o 'Release v[0-9]*\.[0-9]*\.[0-9]*' | sed 's/Release v//' || echo "") | |
| if [[ -n "$VERSION" ]]; then | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "is_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create GitHub Release | |
| if: steps.check_release.outputs.is_release == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ steps.check_release.outputs.version }}" | |
| gh release create "v${VERSION}" \ | |
| --title "Release v${VERSION}" \ | |
| --generate-notes |