|
| 1 | +name: Drop CLI Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - "drop-core/**" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build ${{ matrix.target }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + # Linux targets |
| 18 | + - os: ubuntu-latest |
| 19 | + target: x86_64-unknown-linux-gnu |
| 20 | + archive: tar.gz |
| 21 | + - os: ubuntu-latest |
| 22 | + target: x86_64-unknown-linux-musl |
| 23 | + archive: tar.gz |
| 24 | + - os: ubuntu-latest |
| 25 | + target: aarch64-unknown-linux-gnu |
| 26 | + archive: tar.gz |
| 27 | + - os: ubuntu-latest |
| 28 | + target: aarch64-unknown-linux-musl |
| 29 | + archive: tar.gz |
| 30 | + - os: ubuntu-latest |
| 31 | + target: armv7-unknown-linux-gnueabihf |
| 32 | + archive: tar.gz |
| 33 | + - os: ubuntu-latest |
| 34 | + target: armv7-unknown-linux-musleabihf |
| 35 | + archive: tar.gz |
| 36 | + |
| 37 | + # Windows targets |
| 38 | + - os: windows-latest |
| 39 | + target: x86_64-pc-windows-msvc |
| 40 | + archive: zip |
| 41 | + - os: windows-latest |
| 42 | + target: i686-pc-windows-msvc |
| 43 | + archive: zip |
| 44 | + - os: windows-latest |
| 45 | + target: aarch64-pc-windows-msvc |
| 46 | + archive: zip |
| 47 | + |
| 48 | + # macOS targets |
| 49 | + - os: macos-latest |
| 50 | + target: x86_64-apple-darwin |
| 51 | + archive: tar.gz |
| 52 | + - os: macos-latest |
| 53 | + target: aarch64-apple-darwin |
| 54 | + archive: tar.gz |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout code |
| 58 | + uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Install Rust toolchain |
| 61 | + uses: dtolnay/rust-toolchain@stable |
| 62 | + with: |
| 63 | + toolchain: 1.75.0 |
| 64 | + targets: ${{ matrix.target }} |
| 65 | + |
| 66 | + - name: Install additional targets |
| 67 | + run: | |
| 68 | + rustup target add ${{ matrix.target }} |
| 69 | +
|
| 70 | + - name: Set up Cargo cache |
| 71 | + uses: Swatinem/rust-cache@v2 |
| 72 | + with: |
| 73 | + key: ${{ matrix.target }} |
| 74 | + |
| 75 | + - name: Install cross-compilation tools (Linux) |
| 76 | + if: matrix.os == 'ubuntu-latest' |
| 77 | + run: | |
| 78 | + sudo apt-get update |
| 79 | + case "${{ matrix.target }}" in |
| 80 | + aarch64-unknown-linux-gnu) |
| 81 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 82 | + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV |
| 83 | + ;; |
| 84 | + aarch64-unknown-linux-musl) |
| 85 | + sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools |
| 86 | + echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV |
| 87 | + ;; |
| 88 | + armv7-unknown-linux-gnueabihf) |
| 89 | + sudo apt-get install -y gcc-arm-linux-gnueabihf |
| 90 | + echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV |
| 91 | + ;; |
| 92 | + armv7-unknown-linux-musleabihf) |
| 93 | + sudo apt-get install -y gcc-arm-linux-gnueabihf musl-tools |
| 94 | + echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV |
| 95 | + ;; |
| 96 | + x86_64-unknown-linux-musl) |
| 97 | + sudo apt-get install -y musl-tools |
| 98 | + ;; |
| 99 | + esac |
| 100 | +
|
| 101 | + - name: Build binary |
| 102 | + run: | |
| 103 | + cargo build --release --target ${{ matrix.target }} --package drop-cli |
| 104 | +
|
| 105 | + - name: Create archive name |
| 106 | + id: archive |
| 107 | + shell: bash |
| 108 | + run: | |
| 109 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 110 | + VERSION="${{ github.event.inputs.version }}" |
| 111 | + else |
| 112 | + VERSION="drop-cli-v${{ github.run_id }}" |
| 113 | + VERSION="${VERSION#drop-cli-v}" |
| 114 | + fi |
| 115 | + ARCHIVE_NAME="drop-cli-${VERSION}-${{ matrix.target }}" |
| 116 | + echo "name=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT |
| 117 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 118 | +
|
| 119 | + - name: Create archive (Unix) |
| 120 | + if: matrix.archive == 'tar.gz' |
| 121 | + run: | |
| 122 | + cd target/${{ matrix.target }}/release |
| 123 | + if [ "${{ matrix.target }}" == *"windows"* ]; then |
| 124 | + BINARY_NAME="drop-cli.exe" |
| 125 | + else |
| 126 | + BINARY_NAME="drop-cli" |
| 127 | + fi |
| 128 | + tar -czf ${{ steps.archive.outputs.name }}.tar.gz ${BINARY_NAME} |
| 129 | + mv ${{ steps.archive.outputs.name }}.tar.gz ${{ github.workspace }}/ |
| 130 | +
|
| 131 | + - name: Create archive (Windows) |
| 132 | + if: matrix.archive == 'zip' |
| 133 | + shell: pwsh |
| 134 | + run: | |
| 135 | + cd target/${{ matrix.target }}/release |
| 136 | + Compress-Archive -Path "drop-cli.exe" -DestinationPath "${{ github.workspace }}/${{ steps.archive.outputs.name }}.zip" |
| 137 | +
|
| 138 | + - name: Upload artifact |
| 139 | + uses: actions/upload-artifact@v4 |
| 140 | + with: |
| 141 | + name: ${{ steps.archive.outputs.name }} |
| 142 | + path: ${{ steps.archive.outputs.name }}.${{ matrix.archive }} |
| 143 | + |
| 144 | + release: |
| 145 | + name: Create Release |
| 146 | + needs: build |
| 147 | + runs-on: ubuntu-latest |
| 148 | + permissions: |
| 149 | + contents: write |
| 150 | + steps: |
| 151 | + - name: Checkout code |
| 152 | + uses: actions/checkout@v4 |
| 153 | + |
| 154 | + - name: Set version |
| 155 | + id: version |
| 156 | + run: | |
| 157 | + TAG_NAME="drop-cli-v${{ github.run_id }}" |
| 158 | + VERSION="${TAG_NAME#drop-cli-v}" |
| 159 | + echo "version=${VERSION}" >> $GITHUB_OUTPUT |
| 160 | + echo "tag=${TAG_NAME}" >> $GITHUB_OUTPUT |
| 161 | +
|
| 162 | + - name: Download all artifacts |
| 163 | + uses: actions/download-artifact@v4 |
| 164 | + with: |
| 165 | + path: artifacts |
| 166 | + |
| 167 | + - name: Create release notes |
| 168 | + id: release_notes |
| 169 | + run: | |
| 170 | + cat > release_notes.md << 'EOF' |
| 171 | + ## Drop CLI ${{ steps.version.outputs.version }} |
| 172 | +
|
| 173 | + ### Downloads |
| 174 | +
|
| 175 | + Choose the appropriate binary for your platform: |
| 176 | +
|
| 177 | + #### Linux |
| 178 | + - **x86_64 (glibc)**: `drop-cli-${{ steps.version.outputs.version }}-x86_64-unknown-linux-gnu.tar.gz` |
| 179 | + - **x86_64 (musl)**: `drop-cli-${{ steps.version.outputs.version }}-x86_64-unknown-linux-musl.tar.gz` |
| 180 | + - **ARM64 (glibc)**: `drop-cli-${{ steps.version.outputs.version }}-aarch64-unknown-linux-gnu.tar.gz` |
| 181 | + - **ARM64 (musl)**: `drop-cli-${{ steps.version.outputs.version }}-aarch64-unknown-linux-musl.tar.gz` |
| 182 | + - **ARMv7 (glibc)**: `drop-cli-${{ steps.version.outputs.version }}-armv7-unknown-linux-gnueabihf.tar.gz` |
| 183 | + - **ARMv7 (musl)**: `drop-cli-${{ steps.version.outputs.version }}-armv7-unknown-linux-musleabihf.tar.gz` |
| 184 | +
|
| 185 | + #### Windows |
| 186 | + - **x86_64**: `drop-cli-${{ steps.version.outputs.version }}-x86_64-pc-windows-msvc.zip` |
| 187 | + - **x86**: `drop-cli-${{ steps.version.outputs.version }}-i686-pc-windows-msvc.zip` |
| 188 | + - **ARM64**: `drop-cli-${{ steps.version.outputs.version }}-aarch64-pc-windows-msvc.zip` |
| 189 | +
|
| 190 | + #### macOS |
| 191 | + - **Intel (x86_64)**: `drop-cli-${{ steps.version.outputs.version }}-x86_64-apple-darwin.tar.gz` |
| 192 | + - **Apple Silicon (ARM64)**: `drop-cli-${{ steps.version.outputs.version }}-aarch64-apple-darwin.tar.gz` |
| 193 | +
|
| 194 | + ### Installation |
| 195 | +
|
| 196 | + 1. Download the appropriate binary for your platform |
| 197 | + 2. Extract the archive |
| 198 | + 3. Move the binary to a location in your PATH (e.g., `/usr/local/bin` on Unix systems) |
| 199 | + 4. Make it executable (Unix systems): `chmod +x drop-cli` |
| 200 | +
|
| 201 | + ### Usage |
| 202 | +
|
| 203 | + Run `drop-cli --help` to see available commands and options. |
| 204 | + EOF |
| 205 | +
|
| 206 | + - name: Create or update release |
| 207 | + uses: softprops/action-gh-release@v1 |
| 208 | + with: |
| 209 | + tag_name: ${{ steps.version.outputs.tag }} |
| 210 | + name: Drop CLI ${{ steps.version.outputs.version }} |
| 211 | + body_path: release_notes.md |
| 212 | + files: artifacts/drop-cli-*/* |
| 213 | + draft: false |
| 214 | + prerelease: false |
| 215 | + env: |
| 216 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments