|
| 1 | +name: Continuous Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + |
| 6 | +jobs: |
| 7 | + # checks that the build can run on all platforms |
| 8 | + # This is a copy of the publish-binaries job in cd.yml without any publishing steps. |
| 9 | + build-binaries: |
| 10 | + name: Publish binaries |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - name: linux-x64-glibc |
| 17 | + os: ubuntu-latest |
| 18 | + target: x86_64-unknown-linux-gnu |
| 19 | + publish_npm: true |
| 20 | + publish_pypi: true |
| 21 | + - name: linux-x64-musl |
| 22 | + os: ubuntu-latest |
| 23 | + target: x86_64-unknown-linux-musl |
| 24 | + publish_npm: false |
| 25 | + publish_pypi: true |
| 26 | + install_musl: true |
| 27 | + - name: linux-x86-glibc |
| 28 | + os: ubuntu-latest |
| 29 | + target: i686-unknown-linux-gnu |
| 30 | + publish_npm: false |
| 31 | + publish_pypi: false |
| 32 | + - name: linux-x86-musl |
| 33 | + os: ubuntu-latest |
| 34 | + target: i686-unknown-linux-musl |
| 35 | + publish_npm: false |
| 36 | + publish_pypi: true |
| 37 | + install_musl: true |
| 38 | + - name: linux-arm64-glibc |
| 39 | + os: ubuntu-24.04-arm |
| 40 | + target: aarch64-unknown-linux-gnu |
| 41 | + publish_npm: true |
| 42 | + publish_pypi: true |
| 43 | + - name: linux-arm64-musl |
| 44 | + os: ubuntu-24.04-arm |
| 45 | + target: aarch64-unknown-linux-musl |
| 46 | + publish_npm: false |
| 47 | + publish_pypi: true |
| 48 | + install_musl: true |
| 49 | + - name: win32-x64-mingw |
| 50 | + os: windows-latest |
| 51 | + target: x86_64-pc-windows-gnu |
| 52 | + publish_npm: false |
| 53 | + publish_pypi: false |
| 54 | + - name: win32-x64-msvc |
| 55 | + os: windows-latest |
| 56 | + target: x86_64-pc-windows-msvc |
| 57 | + publish_npm: true |
| 58 | + publish_pypi: true |
| 59 | + - name: win32-x86-msvc |
| 60 | + os: windows-latest |
| 61 | + target: i686-pc-windows-msvc |
| 62 | + publish_npm: false |
| 63 | + publish_pypi: true |
| 64 | + - name: win32-arm64-msvc |
| 65 | + os: windows-11-arm |
| 66 | + target: aarch64-pc-windows-msvc |
| 67 | + publish_npm: true |
| 68 | + publish_pypi: false |
| 69 | + - name: darwin-x64 |
| 70 | + os: macos-13 |
| 71 | + target: x86_64-apple-darwin |
| 72 | + publish_npm: true |
| 73 | + publish_pypi: true |
| 74 | + - name: darwin-arm64 |
| 75 | + os: macos-latest |
| 76 | + target: aarch64-apple-darwin |
| 77 | + publish_npm: true |
| 78 | + publish_pypi: true |
| 79 | + steps: |
| 80 | + - name: Checkout |
| 81 | + uses: actions/checkout@v4 |
| 82 | + - name: Set the release version |
| 83 | + shell: bash |
| 84 | + run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV |
| 85 | + - name: Install Musl tools |
| 86 | + if: matrix.install_musl |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + sudo apt-get update |
| 90 | + sudo apt-get install -y --no-install-recommends --allow-unauthenticated \ |
| 91 | + musl-tools |
| 92 | + - name: Install Rust toolchain |
| 93 | + uses: dtolnay/rust-toolchain@stable |
| 94 | + with: |
| 95 | + targets: ${{ matrix.target }} |
| 96 | + - name: Build |
| 97 | + run: cargo build --release --locked --target ${{ matrix.target }} |
| 98 | + - name: Prepare release assets |
| 99 | + shell: bash |
| 100 | + run: | |
| 101 | + mkdir -p release/{man,completions} |
| 102 | + cp {LICENSE-MIT,LICENSE-APACHE,README.md,CHANGELOG.md} release/ |
| 103 | + OUT_DIR=release/completions/ cargo run --release --bin git-cliff-completions |
| 104 | + OUT_DIR=release/man/ cargo run --release --bin git-cliff-mangen |
| 105 | + for bin in 'git-cliff' 'git-cliff-completions' 'git-cliff-mangen'; do |
| 106 | + if [ "${{ contains(matrix.os, 'windows') }}" = "true" ]; then |
| 107 | + bin="${bin}.exe" |
| 108 | + fi |
| 109 | + cp "target/${{ matrix.target }}/release/${bin}" release/ |
| 110 | + done |
| 111 | + mv release/ git-cliff-${{ env.RELEASE_VERSION }}/ |
| 112 | + - name: Create release artifacts |
| 113 | + shell: bash |
| 114 | + run: | |
| 115 | + if [ "${{ contains(matrix.os, 'windows') }}" = "true" ]; then |
| 116 | + 7z a -tzip "git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.zip" \ |
| 117 | + git-cliff-${{ env.RELEASE_VERSION }}/ |
| 118 | + else |
| 119 | + tar -czvf git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz \ |
| 120 | + git-cliff-${{ env.RELEASE_VERSION }}/ |
| 121 | + shasum -a 512 git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz \ |
| 122 | + > git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz.sha512 |
| 123 | + fi |
| 124 | + - name: Sign the release |
| 125 | + if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') |
| 126 | + run: | |
| 127 | + echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key |
| 128 | + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \ |
| 129 | + --passphrase-fd 0 --import private.key |
| 130 | + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \ |
| 131 | + --passphrase-fd 0 --detach-sign \ |
| 132 | + git-cliff-${{ env.RELEASE_VERSION }}-${{ matrix.target }}.tar.gz |
| 133 | + - name: Build Python wheels (linux) |
| 134 | + if: matrix.publish_pypi && startsWith(matrix.name, 'linux') |
| 135 | + uses: PyO3/maturin-action@v1 |
| 136 | + with: |
| 137 | + working-directory: pypi |
| 138 | + target: ${{ matrix.target }} |
| 139 | + args: --release --sdist --out wheels |
| 140 | + sccache: "true" |
| 141 | + # https://github.com/PyO3/maturin-action/issues/245 |
| 142 | + manylinux: ${{ matrix.target == 'aarch64-unknown-linux-gnu' && '2_28' || 'auto' }} |
| 143 | + - name: Build Python wheels (macos & windows) |
| 144 | + if: matrix.publish_pypi && (contains(matrix.os, 'macos') || contains(matrix.os, 'windows')) |
| 145 | + uses: PyO3/maturin-action@v1 |
| 146 | + with: |
| 147 | + working-directory: pypi |
| 148 | + target: ${{ matrix.target }} |
| 149 | + args: --release --sdist --out wheels |
| 150 | + sccache: "true" |
| 151 | + - name: Build Python wheels (musl) |
| 152 | + if: matrix.publish_pypi && matrix.install_musl |
| 153 | + uses: PyO3/maturin-action@v1 |
| 154 | + with: |
| 155 | + working-directory: pypi |
| 156 | + target: ${{ matrix.target }} |
| 157 | + args: --release --sdist --out wheels |
| 158 | + sccache: "true" |
| 159 | + manylinux: musllinux_1_2 |
0 commit comments