diff options
| author | diogo464 <[email protected]> | 2025-07-10 22:20:34 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-10 22:20:34 +0100 |
| commit | 0ead2c37efe34278a859edbce40e8bba7bf021fd (patch) | |
| tree | aaf17c0a8bd10b596962ae52f25e8bcb0e62dea8 /.github | |
| parent | 3b0721341c46922b5c1c94bdbbf37099424ee5bc (diff) | |
Add GitHub Actions release workflow and build scripts
- Add .github/workflows/release.yml for automated releases on version tags
- Add scripts/build-static.sh for building statically linked binaries
- Add scripts/prepare-release.sh for preparing release artifacts
- Optimize Cargo.toml for smaller binary size (reduced from 4.5MB to 2.9MB)
- Add scripts/README.md with usage documentation
The workflow automatically builds binaries for Linux (musl) and macOS (Intel/ARM)
when a version tag is pushed.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to '.github')
| -rw-r--r-- | .github/workflows/release.yml | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4a040e7 --- /dev/null +++ b/.github/workflows/release.yml | |||
| @@ -0,0 +1,169 @@ | |||
| 1 | name: Release | ||
| 2 | |||
| 3 | on: | ||
| 4 | push: | ||
| 5 | tags: | ||
| 6 | - 'v*' | ||
| 7 | |||
| 8 | permissions: | ||
| 9 | contents: write | ||
| 10 | |||
| 11 | jobs: | ||
| 12 | build: | ||
| 13 | name: Build Release Binaries | ||
| 14 | runs-on: ${{ matrix.os }} | ||
| 15 | strategy: | ||
| 16 | matrix: | ||
| 17 | include: | ||
| 18 | # Linux builds | ||
| 19 | - os: ubuntu-latest | ||
| 20 | target: x86_64-unknown-linux-musl | ||
| 21 | platform: linux-x86_64 | ||
| 22 | |||
| 23 | # macOS builds | ||
| 24 | - os: macos-latest | ||
| 25 | target: x86_64-apple-darwin | ||
| 26 | platform: macos-x86_64 | ||
| 27 | |||
| 28 | - os: macos-latest | ||
| 29 | target: aarch64-apple-darwin | ||
| 30 | platform: macos-aarch64 | ||
| 31 | |||
| 32 | steps: | ||
| 33 | - name: Checkout code | ||
| 34 | uses: actions/checkout@v4 | ||
| 35 | |||
| 36 | - name: Install Rust toolchain | ||
| 37 | uses: dtolnay/rust-toolchain@nightly | ||
| 38 | with: | ||
| 39 | targets: ${{ matrix.target }} | ||
| 40 | |||
| 41 | - name: Install dependencies (Linux) | ||
| 42 | if: runner.os == 'Linux' | ||
| 43 | run: | | ||
| 44 | sudo apt-get update | ||
| 45 | sudo apt-get install -y musl-tools | ||
| 46 | |||
| 47 | - name: Cache cargo registry | ||
| 48 | uses: actions/cache@v3 | ||
| 49 | with: | ||
| 50 | path: ~/.cargo/registry | ||
| 51 | key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||
| 52 | |||
| 53 | - name: Cache cargo index | ||
| 54 | uses: actions/cache@v3 | ||
| 55 | with: | ||
| 56 | path: ~/.cargo/git | ||
| 57 | key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||
| 58 | |||
| 59 | - name: Cache cargo build | ||
| 60 | uses: actions/cache@v3 | ||
| 61 | with: | ||
| 62 | path: target | ||
| 63 | key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | ||
| 64 | |||
| 65 | - name: Build binary | ||
| 66 | env: | ||
| 67 | RUSTFLAGS: "-C target-feature=+crt-static" | ||
| 68 | run: | | ||
| 69 | cargo build --release --target ${{ matrix.target }} | ||
| 70 | |||
| 71 | - name: Strip binary (Linux) | ||
| 72 | if: runner.os == 'Linux' | ||
| 73 | run: | | ||
| 74 | strip target/${{ matrix.target }}/release/oar-p2p | ||
| 75 | |||
| 76 | - name: Strip binary (macOS) | ||
| 77 | if: runner.os == 'macOS' | ||
| 78 | run: | | ||
| 79 | strip target/${{ matrix.target }}/release/oar-p2p || true | ||
| 80 | |||
| 81 | - name: Create tarball | ||
| 82 | run: | | ||
| 83 | cd target/${{ matrix.target }}/release | ||
| 84 | tar -czf ../../../oar-p2p-${{ github.ref_name }}-${{ matrix.platform }}.tar.gz oar-p2p | ||
| 85 | cd ../../.. | ||
| 86 | |||
| 87 | - name: Upload artifact | ||
| 88 | uses: actions/upload-artifact@v3 | ||
| 89 | with: | ||
| 90 | name: oar-p2p-${{ matrix.platform }} | ||
| 91 | path: oar-p2p-${{ github.ref_name }}-${{ matrix.platform }}.tar.gz | ||
| 92 | |||
| 93 | release: | ||
| 94 | name: Create Release | ||
| 95 | needs: build | ||
| 96 | runs-on: ubuntu-latest | ||
| 97 | |||
| 98 | steps: | ||
| 99 | - name: Checkout code | ||
| 100 | uses: actions/checkout@v4 | ||
| 101 | |||
| 102 | - name: Download artifacts | ||
| 103 | uses: actions/download-artifact@v3 | ||
| 104 | with: | ||
| 105 | path: artifacts | ||
| 106 | |||
| 107 | - name: Move artifacts to release directory | ||
| 108 | run: | | ||
| 109 | mkdir -p release | ||
| 110 | mv artifacts/*/*.tar.gz release/ | ||
| 111 | |||
| 112 | - name: Generate checksums | ||
| 113 | run: | | ||
| 114 | cd release | ||
| 115 | sha256sum *.tar.gz > checksums-sha256.txt | ||
| 116 | sha512sum *.tar.gz > checksums-sha512.txt | ||
| 117 | |||
| 118 | - name: Generate release notes | ||
| 119 | run: | | ||
| 120 | VERSION="${{ github.ref_name }}" | ||
| 121 | VERSION_NUMBER="${VERSION#v}" | ||
| 122 | |||
| 123 | cat > release-notes.md << EOF | ||
| 124 | # Release ${{ github.ref_name }} | ||
| 125 | |||
| 126 | ## Installation | ||
| 127 | |||
| 128 | ### Linux x86_64 | ||
| 129 | \`\`\`bash | ||
| 130 | curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/oar-p2p-${{ github.ref_name }}-linux-x86_64.tar.gz | tar -xz | ||
| 131 | sudo mv oar-p2p /usr/local/bin/ | ||
| 132 | \`\`\` | ||
| 133 | |||
| 134 | ### macOS Intel | ||
| 135 | \`\`\`bash | ||
| 136 | curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/oar-p2p-${{ github.ref_name }}-macos-x86_64.tar.gz | tar -xz | ||
| 137 | sudo mv oar-p2p /usr/local/bin/ | ||
| 138 | \`\`\` | ||
| 139 | |||
| 140 | ### macOS Apple Silicon | ||
| 141 | \`\`\`bash | ||
| 142 | curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/oar-p2p-${{ github.ref_name }}-macos-aarch64.tar.gz | tar -xz | ||
| 143 | sudo mv oar-p2p /usr/local/bin/ | ||
| 144 | \`\`\` | ||
| 145 | |||
| 146 | ## Checksums | ||
| 147 | |||
| 148 | ### SHA256 | ||
| 149 | \`\`\` | ||
| 150 | $(cat release/checksums-sha256.txt) | ||
| 151 | \`\`\` | ||
| 152 | |||
| 153 | ### SHA512 | ||
| 154 | \`\`\` | ||
| 155 | $(cat release/checksums-sha512.txt) | ||
| 156 | \`\`\` | ||
| 157 | EOF | ||
| 158 | |||
| 159 | - name: Create GitHub Release | ||
| 160 | uses: softprops/action-gh-release@v1 | ||
| 161 | with: | ||
| 162 | files: | | ||
| 163 | release/*.tar.gz | ||
| 164 | release/checksums-*.txt | ||
| 165 | body_path: release-notes.md | ||
| 166 | draft: false | ||
| 167 | prerelease: false | ||
| 168 | env: | ||
| 169 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file | ||
