Decimal improvements #551
Workflow file for this run
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: Rust Build and Artifact Creation | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| permissions: | |
| contents: write | |
| # For syyyr/rust-pycobertura-action | |
| pull-requests: write | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| toolchain: [stable, nightly] | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| toolchain: ${{ matrix.toolchain }} | |
| override: true | |
| - name: Build and Install Binary | |
| run: | | |
| mkdir -p ${{github.workspace}}/install | |
| # FIXME: Remove when this thing makes it into stable | |
| export RUSTFLAGS="-A mismatched_lifetime_syntaxes" | |
| cargo install --path '${{github.workspace}}' --root '${{github.workspace}}/install' --target ${{ matrix.target }} --features cp2cp --locked | |
| shell: bash | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.os }}-${{ matrix.toolchain }}-binary | |
| path: ${{github.workspace}}/install/bin | |
| create-nightly-release: | |
| name: Create nightly | |
| if: github.ref == 'refs/heads/master' | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| env: | |
| HASH_FOR_FILENAMES: ${{github.event.pull_request.head.sha || github.sha}} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Consolidate artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: '*-latest-nightly-binary' | |
| merge-multiple: true | |
| - name: Rename artifacts | |
| run: | | |
| CP2CP_FILE_NAME="$(printf "cp2cp-nightly-g%s" "$(head -c 7 <<< '${{env.HASH_FOR_FILENAMES}}')")" | |
| mv cp2cp "${CP2CP_FILE_NAME}" | |
| mv cp2cp.exe "${CP2CP_FILE_NAME}.exe" | |
| - name: Create release | |
| env: | |
| GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| uses: silicon-heaven/rust-nightly-release-action@v1.0.0 | |
| with: | |
| path_glob: cp2cp* | |
| coverage: | |
| name: Code coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate coverage | |
| uses: silicon-heaven/rust-pycobertura-action@v4.0.1 | |
| with: | |
| project_name: libshvproto | |
| cargo_test_arguments: --features cp2cp | |
| check-version-bump: | |
| name: Check version bump | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check version bump | |
| id: version-check | |
| continue-on-error: ${{startsWith(github.head_ref, 'dependabot/')}} | |
| uses: silicon-heaven/rust-check-version-bump@v1.0.1 | |
| - name: Checkout code | |
| if: steps.version-check.outcome == 'failure' | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{github.head_ref}} | |
| - name: Bump version | |
| if: steps.version-check.outcome == 'failure' | |
| run: | | |
| [[ "$(grep '^version' Cargo.toml | head -n1)" =~ ([0-9]+\.[0-9]+\.)([0-9]+) ]] | |
| NEW_VERSION="${BASH_REMATCH[1]}$((BASH_REMATCH[2] + 1))" | |
| echo Bumping "${BASH_REMATCH[0]} -> $NEW_VERSION" | |
| sed -i "s/${BASH_REMATCH[0]}/$NEW_VERSION/" Cargo.toml | |
| if [[ -f Cargo.lock ]]; then | |
| cargo update | |
| fi | |
| git diff | |
| git config --global user.name "Login will be determined by the Github API based on the creator of the token" | |
| git config --global user.email "" | |
| git commit -am '[dependabot-skip] Bump version' | |
| - name: Push changes | |
| if: steps.version-check.outcome == 'failure' | |
| uses: Asana/push-signed-commits@v1 | |
| with: | |
| github-token: ${{ secrets.DEPENDABOT_GITHUB_TOKEN }} | |
| local_branch_name: ${{github.head_ref}} | |
| remote_branch_name: ${{github.head_ref}} | |
| tag-release: | |
| name: Tag Release | |
| if: github.ref == 'refs/heads/master' | |
| needs: [build, check-version-bump] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version from Cargo.toml | |
| id: get-version | |
| run: | | |
| version="$(grep '^version' Cargo.toml | head -n1 | sed 's/version\s*=\s*"\(.*\)"/\1/')" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Create and push tag | |
| uses: rickstaa/action-create-tag@v1 | |
| with: | |
| tag: ${{ steps.get-version.outputs.version }} | |
| upload-crates-io: | |
| name: Publish crates on crates.io | |
| if: github.ref == 'refs/heads/master' | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - run: | | |
| cargo login <<< "${{secrets.CRATES_IO_TOKEN}}" | |
| if ! PUBLISH_OUTPUT="$(cargo publish --workspace 2>&1)"; then | |
| echo "$PUBLISH_OUTPUT" | |
| if ! [[ "$PUBLISH_OUTPUT" =~ already\ exists\ on\ crates.io\ index ]]; then | |
| exit 1 | |
| fi | |
| echo Some crates were already published. | |
| else | |
| echo "$PUBLISH_OUTPUT" | |
| fi |