aboutsummaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/release.yml169
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 @@
1name: Release
2
3on:
4 push:
5 tags:
6 - 'v*'
7
8permissions:
9 contents: write
10
11jobs:
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