--- name: release on: workflow_dispatch: inputs: version_bump: description: 'Version bump type' required: true default: 'patch' type: choice options: - patch - minor - major permissions: contents: write packages: write env: CARGO_TERM_COLOR: always RUSTUP_TOOLCHAIN: nightly-2025-06-06 jobs: version: runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} tag: ${{ steps.version.outputs.tag }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: setup rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: ${{ env.RUSTUP_TOOLCHAIN }} - name: install cargo-edit run: cargo install cargo-edit --locked - name: get current version id: current_version run: | current=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') echo "current=$current" >> $GITHUB_OUTPUT - name: calculate new version id: version run: | current="${{ steps.current_version.outputs.current }}" bump_type="${{ github.event.inputs.version_bump }}" # Parse current version IFS='.' read -ra VERSION_PARTS <<< "$current" major=${VERSION_PARTS[0]} minor=${VERSION_PARTS[1]} patch=${VERSION_PARTS[2]} # Calculate new version case $bump_type in major) major=$((major + 1)) minor=0 patch=0 ;; minor) minor=$((minor + 1)) patch=0 ;; patch) patch=$((patch + 1)) ;; esac new_version="$major.$minor.$patch" tag="v$new_version" echo "version=$new_version" >> $GITHUB_OUTPUT echo "tag=$tag" >> $GITHUB_OUTPUT echo "New version will be: $new_version" - name: update Cargo.toml version run: | cargo set-version ${{ steps.version.outputs.version }} - name: commit version bump run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add Cargo.toml Cargo.lock git commit -m "bump version to v${{ steps.version.outputs.version }}" git push origin main - name: create tag run: | git tag ${{ steps.version.outputs.tag }} git push origin ${{ steps.version.outputs.tag }} build: needs: version runs-on: ${{ matrix.os }} strategy: matrix: include: - os: ubuntu-latest target: x86_64-unknown-linux-gnu binary_name: quantus-miner asset_name: quantus-miner-linux-x86_64 - os: windows-latest target: x86_64-pc-windows-msvc binary_name: quantus-miner.exe asset_name: quantus-miner-windows-x86_64.exe - os: macos-latest target: aarch64-apple-darwin binary_name: quantus-miner asset_name: quantus-miner-macos-aarch64 steps: - uses: actions/checkout@v4 with: ref: ${{ needs.version.outputs.tag }} - name: setup rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: ${{ env.RUSTUP_TOOLCHAIN }} target: ${{ matrix.target }} - name: build binary run: cargo build --release --locked --target ${{ matrix.target }} - name: prepare binary shell: bash run: | cd target/${{ matrix.target }}/release if [[ "${{ matrix.os }}" == "windows-latest" ]]; then cp ${{ matrix.binary_name }} ${{ matrix.asset_name }} else cp ${{ matrix.binary_name }} ${{ matrix.asset_name }} strip ${{ matrix.asset_name }} fi - name: upload binary artifact uses: actions/upload-artifact@v4 with: name: ${{ matrix.asset_name }} path: target/${{ matrix.target }}/release/${{ matrix.asset_name }} release: needs: [version, build] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ needs.version.outputs.tag }} - name: download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: create release uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.version.outputs.tag }} name: Release ${{ needs.version.outputs.tag }} draft: false prerelease: false generate_release_notes: true files: | artifacts/quantus-miner-linux-x86_64/quantus-miner-linux-x86_64 artifacts/quantus-miner-windows-x86_64.exe/quantus-miner-windows-x86_64.exe artifacts/quantus-miner-macos-aarch64/quantus-miner-macos-aarch64 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}