|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build ${{ matrix.target }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - target: x86_64-unknown-linux-gnu |
| 20 | + os: ubuntu-latest |
| 21 | + - target: x86_64-pc-windows-msvc |
| 22 | + os: windows-latest |
| 23 | + - target: x86_64-apple-darwin |
| 24 | + os: macos-latest |
| 25 | + - target: aarch64-apple-darwin |
| 26 | + os: macos-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Install Rust |
| 33 | + uses: dtolnay/rust-toolchain@stable |
| 34 | + with: |
| 35 | + targets: ${{ matrix.target }} |
| 36 | + |
| 37 | + - name: Install dependencies (Ubuntu) |
| 38 | + if: matrix.os == 'ubuntu-latest' |
| 39 | + run: | |
| 40 | + sudo apt-get update |
| 41 | + sudo apt-get install -y libssl-dev pkg-config |
| 42 | +
|
| 43 | + - name: Build |
| 44 | + run: cargo build --release --target ${{ matrix.target }} |
| 45 | + |
| 46 | + - name: Strip binary (Unix) |
| 47 | + if: runner.os != 'Windows' |
| 48 | + run: strip target/${{ matrix.target }}/release/gribble |
| 49 | + |
| 50 | + - name: Create archive (Unix) |
| 51 | + if: runner.os != 'Windows' |
| 52 | + run: | |
| 53 | + mkdir -p dist |
| 54 | + cp target/${{ matrix.target }}/release/gribble dist/gribble-${{ matrix.target }} |
| 55 | + tar -czf dist/gribble-${{ matrix.target }}.tar.gz -C dist gribble-${{ matrix.target }} |
| 56 | +
|
| 57 | + - name: Create archive (Windows) |
| 58 | + if: runner.os == 'Windows' |
| 59 | + run: | |
| 60 | + mkdir dist |
| 61 | + cp target/${{ matrix.target }}/release/gribble.exe dist/gribble-${{ matrix.target }}.exe |
| 62 | + powershell Compress-Archive -Path dist/gribble-${{ matrix.target }}.exe -DestinationPath dist/gribble-${{ matrix.target }}.zip |
| 63 | +
|
| 64 | + - name: Upload artifacts |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: gribble-${{ matrix.target }} |
| 68 | + path: dist/ |
| 69 | + retention-days: 1 |
| 70 | + |
| 71 | + release: |
| 72 | + name: Create Release |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: build |
| 75 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Checkout repository |
| 79 | + uses: actions/checkout@v4 |
| 80 | + |
| 81 | + - name: Download all artifacts |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + path: artifacts/ |
| 85 | + |
| 86 | + - name: Prepare release assets |
| 87 | + run: | |
| 88 | + mkdir -p release-assets |
| 89 | + find artifacts -name "*.tar.gz" -exec cp {} release-assets/ \; |
| 90 | + find artifacts -name "*.zip" -exec cp {} release-assets/ \; |
| 91 | +
|
| 92 | + - name: Extract tag name |
| 93 | + id: tag |
| 94 | + run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 95 | + |
| 96 | + - name: Generate changelog |
| 97 | + id: changelog |
| 98 | + run: | |
| 99 | + # Get the previous tag |
| 100 | + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 101 | + |
| 102 | + if [ -n "$PREV_TAG" ]; then |
| 103 | + # Generate changelog from commits between tags |
| 104 | + CHANGELOG=$(git log --pretty=format:"- %s" $PREV_TAG..HEAD | head -20) |
| 105 | + else |
| 106 | + # First release - show recent commits |
| 107 | + CHANGELOG=$(git log --pretty=format:"- %s" --max-count=20) |
| 108 | + fi |
| 109 | + |
| 110 | + echo "changelog<<EOF" >> $GITHUB_OUTPUT |
| 111 | + echo "$CHANGELOG" >> $GITHUB_OUTPUT |
| 112 | + echo "EOF" >> $GITHUB_OUTPUT |
| 113 | +
|
| 114 | + - name: Create Release |
| 115 | + uses: softprops/action-gh-release@v1 |
| 116 | + with: |
| 117 | + tag_name: ${{ steps.tag.outputs.tag }} |
| 118 | + name: Release ${{ steps.tag.outputs.tag }} |
| 119 | + body: | |
| 120 | + ## What's Changed |
| 121 | + |
| 122 | + ${{ steps.changelog.outputs.changelog }} |
| 123 | + |
| 124 | + ## Downloads |
| 125 | + |
| 126 | + Choose the appropriate binary for your platform: |
| 127 | + - **Linux (x86_64)**: `gribble-x86_64-unknown-linux-gnu.tar.gz` |
| 128 | + - **Windows (x64)**: `gribble-x86_64-pc-windows-msvc.zip` |
| 129 | + - **macOS (Intel)**: `gribble-x86_64-apple-darwin.tar.gz` |
| 130 | + - **macOS (Apple Silicon)**: `gribble-aarch64-apple-darwin.tar.gz` |
| 131 | + |
| 132 | + ### Installation |
| 133 | + |
| 134 | + **Linux/macOS:** |
| 135 | + ```bash |
| 136 | + tar -xzf gribble-x86_64-unknown-linux-gnu.tar.gz |
| 137 | + sudo mv gribble-x86_64-unknown-linux-gnu /usr/local/bin/gribble |
| 138 | + ``` |
| 139 | + |
| 140 | + **Windows:** |
| 141 | + Extract the zip file and add the directory to your PATH. |
| 142 | + files: release-assets/* |
| 143 | + draft: false |
| 144 | + prerelease: false |
| 145 | + env: |
| 146 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments