feat: make dockerfile use main an option #44
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: Release Publish | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| create-tag: | |
| name: Create Tag | |
| if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release-proposal') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.extract_version.outputs.version }} | |
| tag: ${{ steps.extract_version.outputs.tag }} | |
| is_draft: ${{ steps.extract_version.outputs.is_draft }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from PR title | |
| id: extract_version | |
| run: | | |
| # Extract version from PR title (format: "Release vX.Y.Z") | |
| VERSION_TAG=$(echo "${{ github.event.pull_request.title }}" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+') | |
| if [ -z "$VERSION_TAG" ]; then | |
| echo "Error: Could not extract version from PR title: ${{ github.event.pull_request.title }}" | |
| exit 1 | |
| fi | |
| VERSION=${VERSION_TAG#v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=$VERSION_TAG" >> $GITHUB_OUTPUT | |
| # Check if this is a draft release | |
| if [[ "${{ contains(github.event.pull_request.labels.*.name, 'draft-release') }}" == "true" ]]; then | |
| echo "is_draft=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_draft=false" >> $GITHUB_OUTPUT | |
| fi | |
| echo "Extracted version: $VERSION" | |
| echo "Extracted tag: $VERSION_TAG" | |
| - name: Create and push tag | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| git tag -a "${{ steps.extract_version.outputs.tag }}" -m "Release ${{ steps.extract_version.outputs.tag }}" | |
| git push origin "${{ steps.extract_version.outputs.tag }}" | |
| build: | |
| needs: create-tag | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| # Linux builds | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| binary_name: quantus-miner | |
| asset_name: quantus-miner-linux-x86_64 | |
| # Windows builds | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| binary_name: quantus-miner.exe | |
| asset_name: quantus-miner-windows-x86_64.exe | |
| # macOS builds (Intel) | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| binary_name: quantus-miner | |
| asset_name: quantus-miner-macos-x86_64 | |
| # macOS builds (Apple Silicon) | |
| - 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.create-tag.outputs.tag }} | |
| - name: setup rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| - name: build binary | |
| shell: bash | |
| run: | | |
| if [[ -n "${{ matrix.features }}" ]]; then | |
| cargo build --release --locked --target ${{ matrix.target }} --features ${{ matrix.features }} | |
| else | |
| cargo build --release --locked --target ${{ matrix.target }} | |
| fi | |
| - 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: [create-tag, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.create-tag.outputs.tag }} | |
| - name: download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: create release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG: ${{ needs.create-tag.outputs.tag }} | |
| IS_DRAFT: ${{ needs.create-tag.outputs.is_draft }} | |
| run: | | |
| # Prepare draft flag | |
| if [[ "$IS_DRAFT" == "true" ]]; then | |
| DRAFT_FLAG="--draft" | |
| else | |
| DRAFT_FLAG="" | |
| fi | |
| # Create release with all artifacts | |
| gh release create "$TAG" \ | |
| --title "Release $TAG" \ | |
| --generate-notes \ | |
| $DRAFT_FLAG \ | |
| artifacts/*/quantus-miner-* |