name: Release on: push: tags: - "v*" workflow_dispatch: inputs: tag: description: "Tag to build (e.g. v0.6.7)" required: true run_linux: description: "Build Linux (.deb, .rpm, .snap, binaries)" type: boolean default: true run_arch_native: description: "Build Arch Linux Native (.pkg.tar.zst)" type: boolean default: true run_aur: description: "Update AUR packages (dcr & dcr-bin)" type: boolean default: false run_bsd: description: "Build BSD" type: boolean default: true run_macos: description: "Build macOS" type: boolean default: true run_windows: description: "Build Windows" type: boolean default: true run_publish: description: "Publish to crates.io" type: boolean default: false run_brew: description: "Update Homebrew tap" type: boolean default: false permissions: contents: write jobs: # ── Resolve Tag ──────────────────────────────────────────────────────────── setup: runs-on: ubuntu-latest outputs: tag: ${{ steps.tag.outputs.value }} version: ${{ steps.tag.outputs.version }} prerelease: ${{ steps.tag.outputs.prerelease }} steps: - name: Resolve tag id: tag run: | if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then TAG="${{ github.event.inputs.tag }}" else TAG="${GITHUB_REF_NAME}" fi VERSION="${TAG#v}" [[ "$TAG" == *"-"* ]] && PRERELEASE="true" || PRERELEASE="false" echo "value=${TAG}" >> "$GITHUB_OUTPUT" echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT" # ── Release Notes ────────────────────────────────────────────────────────── notes: needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Prepare Release Notes shell: bash run: | set -euo pipefail tag="${{ needs.setup.outputs.version }}" notes_file=".github/release-notes.md" if grep -q "^## \\[${tag}\\]" CHANGELOG.md; then awk -v ver="$tag" ' $0 ~ "^## \\[" ver "\\]" {found=1; next} found && $0 ~ "^## \\[" {exit} found {print} ' CHANGELOG.md | sed -e '${/^$/d;}' > "$notes_file" else echo "No CHANGELOG section for $tag." > "$notes_file" git log -1 --pretty=format:"%s%n%n%b" >> "$notes_file" fi - name: Upload Notes Artifact uses: actions/upload-artifact@v4 with: name: release-notes path: .github/release-notes.md # ── Linux ────────────────────────────────────────────────────────────────── build-linux: if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }} needs: [setup, notes] runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - target: x86_64-unknown-linux-gnu - target: aarch64-unknown-linux-gnu - target: x86_64-unknown-linux-musl - target: aarch64-unknown-linux-musl steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Download Release Notes uses: actions/download-artifact@v4 with: name: release-notes path: .github - name: Install cargo-zigbuild run: | pip install cargo-zigbuild echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Build run: | if [ "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]; then cargo zigbuild --release --target ${{ matrix.target }} else cargo build --release --target ${{ matrix.target }} fi - name: Prepare Artifact run: | ASSET="dcr-${{ matrix.target }}-${{ needs.setup.outputs.version }}" cp target/${{ matrix.target }}/release/dcr "$ASSET" echo "ASSET_NAME=${ASSET}" >> "$GITHUB_ENV" - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: ${{ env.ASSET_NAME }} body_path: .github/release-notes.md prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── Linux Packages (.deb & .rpm) ─────────────────────────────────────────── build-deb-rpm: if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }} needs: [setup, notes] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Download Release Notes uses: actions/download-artifact@v4 with: name: release-notes path: .github - name: Setup Rust uses: dtolnay/rust-toolchain@stable - name: Install Tools run: | cargo install cargo-deb cargo install cargo-generate-rpm - name: Build Native Release run: cargo build --release - name: Generate .deb Package run: cargo deb --no-build - name: Generate .rpm Package run: cargo generate-rpm - name: Upload Packages to Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: | target/debian/*.deb target/generate-rpm/*.rpm body_path: .github/release-notes.md prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── Snapcraft ────────────────────────────────────────────────────────────── build-snap: if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }} needs: [setup, notes] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Setup Rust uses: dtolnay/rust-toolchain@stable - name: Build Release Binary run: | cargo build --release # Создаем папки для контекста snapcraft, если внутри yaml завязан относительный путь mkdir -p dist cp target/release/dcr dist/ - name: Build Snap Package uses: snapcore/action-build@v1 id: snapcraft with: path: packages/snap - name: Upload Snap to Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: packages/snap/*.snap prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── macOS ────────────────────────────────────────────────────────────────── build-macos: if: ${{ github.event_name == 'push' || github.event.inputs.run_macos == 'true' }} needs: [setup, notes] strategy: fail-fast: false matrix: include: - os: macos-15-intel target: x86_64-apple-darwin - os: macos-latest target: aarch64-apple-darwin runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Download Release Notes uses: actions/download-artifact@v4 with: name: release-notes path: .github - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Build run: cargo build --release --target ${{ matrix.target }} - name: Prepare Artifact run: | ASSET="dcr-${{ matrix.target }}-${{ needs.setup.outputs.version }}" cp target/${{ matrix.target }}/release/dcr "$ASSET" echo "ASSET_NAME=${ASSET}" >> "$GITHUB_ENV" - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: ${{ env.ASSET_NAME }} body_path: .github/release-notes.md prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── BSD Systems ──────────────────────────────────────────────────────────── build-bsd: if: ${{ github.event_name == 'push' || github.event.inputs.run_bsd == 'true' }} needs: [setup, notes] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Download Release Notes uses: actions/download-artifact@v4 with: name: release-notes path: .github # ── FreeBSD ── - name: Install cargo-zigbuild run: | pip install cargo-zigbuild echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Setup Rust (FreeBSD) uses: dtolnay/rust-toolchain@stable with: targets: x86_64-unknown-freebsd - name: Build FreeBSD run: cargo zigbuild --release --target x86_64-unknown-freebsd - name: Prepare FreeBSD Artifact run: | ASSET="dcr-x86_64-unknown-freebsd-${{ needs.setup.outputs.version }}" cp target/x86_64-unknown-freebsd/release/dcr "$ASSET" echo "FREEBSD_ASSET=${ASSET}" >> "$GITHUB_ENV" # ── OpenBSD ── - name: Build in OpenBSD VM uses: vmactions/openbsd-vm@v1 with: usesh: true run: | pkg_add rust cargo build --release - name: Prepare OpenBSD Artifact run: | ASSET="dcr-x86_64-unknown-openbsd-${{ needs.setup.outputs.version }}" cp target/release/dcr "$ASSET" echo "OPENBSD_ASSET=${ASSET}" >> "$GITHUB_ENV" # ── NetBSD ── - name: Build in NetBSD VM uses: vmactions/netbsd-vm@v1 with: usesh: true run: | pkgin -y install rust cargo build --release - name: Prepare NetBSD Artifact run: | ASSET="dcr-x86_64-unknown-netbsd-${{ needs.setup.outputs.version }}" cp target/release/dcr "$ASSET" echo "NETBSD_ASSET=${ASSET}" >> "$GITHUB_ENV" # ── Assets Upload ── - name: Upload Release Assets uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: | ${{ env.FREEBSD_ASSET }} ${{ env.OPENBSD_ASSET }} ${{ env.NETBSD_ASSET }} body_path: .github/release-notes.md prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── Windows ──────────────────────────────────────────────────────────────── build-windows: if: ${{ github.event_name == 'push' || github.event.inputs.run_windows == 'true' }} needs: [setup, notes] runs-on: windows-latest strategy: fail-fast: false matrix: include: - target: x86_64-pc-windows-msvc - target: aarch64-pc-windows-msvc - target: x86_64-pc-windows-gnu steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Download Release Notes uses: actions/download-artifact@v4 with: name: release-notes path: .github - name: Setup Rust uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Build run: cargo build --release --target ${{ matrix.target }} - name: Prepare Artifact shell: pwsh run: | $asset = "dcr-${{ matrix.target }}-${{ needs.setup.outputs.version }}.exe" Copy-Item "target/${{ matrix.target }}/release/dcr.exe" "$asset" "ASSET_NAME=$asset" >> $env:GITHUB_ENV - name: Upload Release Asset uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: ${{ env.ASSET_NAME }} body_path: .github/release-notes.md prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── Arch Linux Native Package (.pkg.tar.zst) ─────────────────────────────── build-arch-package: if: ${{ github.event_name == 'push' || github.event.inputs.run_arch_native == 'true' }} needs: [setup, notes] runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - name: Build .pkg.tar.zst inside Arch Container run: | PKGVER='${{ needs.setup.outputs.version }}' TAG='${{ needs.setup.outputs.tag }}' SRC_URL="https://github.com/dexoron/dcr/archive/refs/tags/${TAG}.tar.gz" SHA256="$(curl -fsSL "$SRC_URL" | sha256sum | awk '{print $1}')" mkdir -p arch-build cat > arch-build/PKGBUILD <> /etc/sudoers && \ chown -R builduser:builduser /build && \ cd /build && \ su builduser -c 'makepkg -s --noconfirm' " - name: Upload Arch Package Artifact uses: actions/upload-artifact@v4 with: name: arch-package path: arch-build/*.pkg.tar.zst - name: Upload Package to GitHub Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ needs.setup.outputs.tag }} files: arch-build/*.pkg.tar.zst prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} # ── Arch User Repository (dcr) ─────────────────────────────────── publish-aur: if: ${{ (github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') || github.event.inputs.run_aur == 'true' }} needs: [setup] runs-on: ubuntu-latest environment: aur steps: - name: Checkout uses: actions/checkout@v4 - name: Derive checksum id: meta shell: bash run: | set -euo pipefail SRC_URL="https://github.com/dexoron/dcr/archive/refs/tags/${{ needs.setup.outputs.tag }}.tar.gz" SHA256="$(curl -fsSL "$SRC_URL" | sha256sum | awk '{print $1}')" echo "source_url=$SRC_URL" >> "$GITHUB_OUTPUT" echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" - name: Render AUR metadata shell: bash run: | set -euo pipefail PKGVER='${{ needs.setup.outputs.version }}' SRC_URL='${{ steps.meta.outputs.source_url }}' SHA256='${{ steps.meta.outputs.sha256 }}' mkdir -p packages/aur/dcr cat > packages/aur/dcr/PKGBUILD < packages/aur/dcr/.SRCINFO < ~/.ssh/aur chmod 600 ~/.ssh/aur ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts export GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes' git clone "ssh://aur@aur.archlinux.org/${AUR_PACKAGE}.git" aur-repo cp packages/aur/dcr/PKGBUILD aur-repo/PKGBUILD cp packages/aur/dcr/.SRCINFO aur-repo/.SRCINFO cd aur-repo git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" if git diff --quiet; then echo "No AUR changes" exit 0 fi git add PKGBUILD .SRCINFO git commit -m "dcr ${{ needs.setup.outputs.version }}" git push # ── Arch User Repository (dcr-bin) ──────────────────────────────── publish-aur-bin: if: ${{ (github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') || github.event.inputs.run_aur == 'true' }} needs: [setup, build-linux] runs-on: ubuntu-latest environment: aur steps: - name: Checkout uses: actions/checkout@v4 - name: Derive checksum id: meta shell: bash run: | set -euo pipefail BIN_URL="https://github.com/dexoron/dcr/releases/download/${{ needs.setup.outputs.tag }}/dcr-x86_64-unknown-linux-musl-${{ needs.setup.outputs.version }}" SHA256="$(curl -fsSL "$BIN_URL" | sha256sum | awk '{print $1}')" echo "bin_url=$BIN_URL" >> "$GITHUB_OUTPUT" echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" - name: Render AUR Metadata shell: bash run: | set -euo pipefail PKGVER='${{ needs.setup.outputs.version }}' BIN_URL='${{ steps.meta.outputs.bin_url }}' SHA256='${{ steps.meta.outputs.sha256 }}' mkdir -p packages/aur/dcr-bin cat > packages/aur/dcr-bin/PKGBUILD < packages/aur/dcr-bin/.SRCINFO < ~/.ssh/aur chmod 600 ~/.ssh/aur ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts export GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes' git clone "ssh://aur@aur.archlinux.org/${AUR_PACKAGE}.git" aur-repo cp packages/aur/dcr-bin/PKGBUILD aur-repo/PKGBUILD cp packages/aur/dcr-bin/.SRCINFO aur-repo/.SRCINFO cd aur-repo git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" if git diff --quiet; then echo "No AUR changes" exit 0 fi git add PKGBUILD .SRCINFO git commit -m "dcr-bin ${{ needs.setup.outputs.version }}" git push # ── crates.io ────────────────────────────────────────────────────────────── publish-crates: if: | (github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_publish == 'true') needs: [setup, build-linux, build-macos, build-windows, build-bsd] runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 with: ref: ${{ needs.setup.outputs.tag }} - uses: dtolnay/rust-toolchain@stable - name: Publish to crates.io run: cargo publish # ── Homebrew tap ─────────────────────────────────────────────────────────── publish-brew: if: | (github.event_name == 'push' && needs.setup.outputs.prerelease == 'false') || (github.event_name == 'workflow_dispatch' && github.event.inputs.run_brew == 'true') needs: [setup, build-linux, build-macos] runs-on: ubuntu-latest steps: - name: Download release assets and compute sha256 id: sha run: | VERSION="${{ needs.setup.outputs.version }}" BASE="https://github.com/dexoron/dcr/releases/download/v${VERSION}" download_sha() { curl -fsSL "${BASE}/$1" | sha256sum | awk '{print $1}' } echo "linux_x86=$(download_sha "dcr-x86_64-unknown-linux-gnu-${VERSION}")" >> "$GITHUB_OUTPUT" echo "linux_arm=$(download_sha "dcr-aarch64-unknown-linux-gnu-${VERSION}")" >> "$GITHUB_OUTPUT" echo "macos_x86=$(download_sha "dcr-x86_64-apple-darwin-${VERSION}")" >> "$GITHUB_OUTPUT" echo "macos_arm=$(download_sha "dcr-aarch64-apple-darwin-${VERSION}")" >> "$GITHUB_OUTPUT" - name: Checkout homebrew-dexoron uses: actions/checkout@v4 with: repository: dexoron/homebrew-dexoron token: ${{ secrets.HOMEBREW_TAP_TOKEN }} - name: Update Formula/dcr.rb run: | VERSION="${{ needs.setup.outputs.version }}" cat > Formula/dcr.rb < "dcr" end test do system "#{bin}/dcr", "--version" end end FORMULA - name: Commit and push run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add Formula/dcr.rb git diff --staged --quiet && echo "No changes" && exit 0 git commit -m "dcr ${{ needs.setup.outputs.version }}" git push