Skip to content

Commit 275bf06

Browse files
committed
add release
1 parent 99c0d0d commit 275bf06

File tree

4 files changed

+379
-528
lines changed

4 files changed

+379
-528
lines changed

.github/workflows/release.yml

Lines changed: 140 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,67 @@ jobs:
1616
upload_url: ${{ steps.create_release.outputs.upload_url }}
1717
version: ${{ steps.get_version.outputs.version }}
1818
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
1922
- name: Get version from tag
2023
id: get_version
2124
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
2225

26+
- name: Generate changelog
27+
id: changelog
28+
run: |
29+
if [ -f CHANGELOG.md ]; then
30+
# Extract changelog for this version
31+
awk '/^## \[?v?${{ steps.get_version.outputs.version }}\]?/{flag=1; next} /^## \[?v?[0-9]/{flag=0} flag' CHANGELOG.md > release_notes.md
32+
if [ ! -s release_notes.md ]; then
33+
echo "### Changes in v${{ steps.get_version.outputs.version }}" > release_notes.md
34+
echo "See the full changelog for details." >> release_notes.md
35+
fi
36+
else
37+
echo "### Release v${{ steps.get_version.outputs.version }}" > release_notes.md
38+
echo "Binary releases for multiple platforms are now available." >> release_notes.md
39+
fi
40+
2341
- name: Create Release
2442
id: create_release
25-
uses: actions/create-release@v1
26-
env:
27-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
uses: softprops/action-gh-release@v2
2844
with:
29-
tag_name: ${{ github.ref }}
30-
release_name: Release v${{ steps.get_version.outputs.version }}
45+
tag_name: ${{ github.ref_name }}
46+
name: Release v${{ steps.get_version.outputs.version }}
47+
body_path: release_notes.md
3148
draft: false
32-
prerelease: false
49+
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
50+
generate_release_notes: true
3351

3452
build-release:
3553
name: Build Release
3654
needs: create-release
3755
runs-on: ${{ matrix.os }}
3856
strategy:
57+
fail-fast: false
3958
matrix:
4059
include:
4160
- os: ubuntu-latest
4261
target: x86_64-unknown-linux-gnu
4362
artifact_name: libdplyr
44-
asset_name: libdplyr-linux-x86_64
63+
asset_name: libdplyr-v${{ needs.create-release.outputs.version }}-linux-x86_64
4564
- os: ubuntu-latest
4665
target: x86_64-unknown-linux-musl
4766
artifact_name: libdplyr
48-
asset_name: libdplyr-linux-x86_64-musl
67+
asset_name: libdplyr-v${{ needs.create-release.outputs.version }}-linux-x86_64-musl
4968
- os: windows-latest
5069
target: x86_64-pc-windows-msvc
5170
artifact_name: libdplyr.exe
52-
asset_name: libdplyr-windows-x86_64.exe
71+
asset_name: libdplyr-v${{ needs.create-release.outputs.version }}-windows-x86_64
5372
- os: macos-latest
5473
target: x86_64-apple-darwin
5574
artifact_name: libdplyr
56-
asset_name: libdplyr-macos-x86_64
75+
asset_name: libdplyr-v${{ needs.create-release.outputs.version }}-macos-x86_64
5776
- os: macos-latest
5877
target: aarch64-apple-darwin
5978
artifact_name: libdplyr
60-
asset_name: libdplyr-macos-aarch64
79+
asset_name: libdplyr-v${{ needs.create-release.outputs.version }}-macos-aarch64
6180

6281
steps:
6382
- name: Checkout code
@@ -79,69 +98,161 @@ jobs:
7998
~/.cargo/registry
8099
~/.cargo/git
81100
target
82-
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
101+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
102+
restore-keys: |
103+
${{ runner.os }}-${{ matrix.target }}-cargo-
83104
84105
- name: Build release binary
85-
run: cargo build --release --target ${{ matrix.target }}
106+
run: cargo build --release --target ${{ matrix.target }} --locked
86107

87108
- name: Strip binary (Unix only)
88109
if: matrix.os != 'windows-latest'
89110
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
90111

112+
- name: Create README for release
113+
shell: bash
114+
run: |
115+
cat > release_readme.txt << 'EOF'
116+
libdplyr v${{ needs.create-release.outputs.version }}
117+
118+
A Rust-based transpiler that converts R dplyr syntax to SQL queries.
119+
120+
Usage:
121+
./libdplyr --help # Show help
122+
./libdplyr -t "data %>% select(name, age)" # Convert dplyr to SQL
123+
./libdplyr -i input.R -o output.sql # Convert file
124+
125+
For more information, visit: https://github.com/mrchypark/libdplyr
126+
EOF
127+
91128
- name: Create archive
92129
shell: bash
93130
run: |
131+
mkdir -p release_files
132+
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release_files/
133+
cp release_readme.txt release_files/README.txt
134+
cp LICENSE release_files/ 2>/dev/null || echo "No LICENSE file found"
135+
94136
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
95-
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
96-
7z a ${{ matrix.asset_name }}.zip ${{ matrix.asset_name }}
137+
cd release_files
138+
7z a ../${{ matrix.asset_name }}.zip *
139+
cd ..
97140
echo "ASSET=${{ matrix.asset_name }}.zip" >> $GITHUB_ENV
141+
echo "ASSET_CONTENT_TYPE=application/zip" >> $GITHUB_ENV
98142
else
99-
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
100-
tar czf ${{ matrix.asset_name }}.tar.gz ${{ matrix.asset_name }}
143+
tar czf ${{ matrix.asset_name }}.tar.gz -C release_files .
101144
echo "ASSET=${{ matrix.asset_name }}.tar.gz" >> $GITHUB_ENV
145+
echo "ASSET_CONTENT_TYPE=application/gzip" >> $GITHUB_ENV
102146
fi
103147
104148
- name: Upload Release Asset
105-
uses: actions/upload-release-asset@v1
106-
env:
107-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
uses: softprops/action-gh-release@v2
108150
with:
109-
upload_url: ${{ needs.create-release.outputs.upload_url }}
110-
asset_path: ./${{ env.ASSET }}
111-
asset_name: ${{ env.ASSET }}
112-
asset_content_type: application/octet-stream
151+
tag_name: v${{ needs.create-release.outputs.version }}
152+
files: ${{ env.ASSET }}
153+
fail_on_unmatched_files: true
113154

114155
publish-crate:
115156
name: Publish to crates.io
116157
needs: [create-release, build-release]
117158
runs-on: ubuntu-latest
159+
if: "!contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc')"
118160
steps:
119161
- name: Checkout code
120162
uses: actions/checkout@v4
121163

122164
- name: Install Rust toolchain
123165
uses: dtolnay/rust-toolchain@stable
124166

167+
- name: Verify version matches tag
168+
run: |
169+
CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
170+
TAG_VERSION="${{ needs.create-release.outputs.version }}"
171+
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
172+
echo "Version mismatch: Cargo.toml has $CARGO_VERSION, tag is $TAG_VERSION"
173+
exit 1
174+
fi
175+
125176
- name: Publish to crates.io
126177
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
178+
continue-on-error: true
127179

128180
update-install-script:
129181
name: Update Install Script
130182
needs: [create-release, build-release]
131183
runs-on: ubuntu-latest
184+
if: "!contains(github.ref_name, 'alpha') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'rc')"
132185
steps:
133186
- name: Checkout code
134187
uses: actions/checkout@v4
188+
with:
189+
token: ${{ secrets.GITHUB_TOKEN }}
135190

136191
- name: Update install script version
137192
run: |
138-
sed -i 's/VERSION=".*"/VERSION="${{ needs.create-release.outputs.version }}"/' install.sh
139-
sed -i 's/VERSION=".*"/VERSION="${{ needs.create-release.outputs.version }}"/' install.ps1
193+
VERSION="${{ needs.create-release.outputs.version }}"
194+
195+
# Update install.sh if it exists
196+
if [ -f install.sh ]; then
197+
sed -i "s/VERSION=\".*\"/VERSION=\"$VERSION\"/" install.sh
198+
sed -i "s/version=\".*\"/version=\"$VERSION\"/" install.sh
199+
fi
200+
201+
# Update install.ps1 if it exists
202+
if [ -f install.ps1 ]; then
203+
sed -i "s/\$VERSION = \".*\"/\$VERSION = \"$VERSION\"/" install.ps1
204+
sed -i "s/\$version = \".*\"/\$version = \"$VERSION\"/" install.ps1
205+
fi
140206
141207
- name: Commit and push updated install scripts
142208
run: |
143209
git config --local user.email "action@github.com"
144210
git config --local user.name "GitHub Action"
145-
git add install.sh install.ps1
146-
git commit -m "Update install scripts to version ${{ needs.create-release.outputs.version }}" || exit 0
147-
git push
211+
212+
if git diff --quiet; then
213+
echo "No changes to commit"
214+
exit 0
215+
fi
216+
217+
git add install.sh install.ps1 2>/dev/null || true
218+
git commit -m "chore: update install scripts to version ${{ needs.create-release.outputs.version }}" || exit 0
219+
git push
220+
221+
create-checksums:
222+
name: Create Checksums
223+
needs: [create-release, build-release]
224+
runs-on: ubuntu-latest
225+
steps:
226+
- name: Download all artifacts
227+
uses: actions/download-artifact@v4
228+
with:
229+
path: artifacts
230+
231+
- name: Create checksums
232+
run: |
233+
cd artifacts
234+
find . -name "*.tar.gz" -o -name "*.zip" | while read file; do
235+
if [ -f "$file" ]; then
236+
sha256sum "$file" >> ../checksums.txt
237+
md5sum "$file" >> ../checksums_md5.txt
238+
fi
239+
done
240+
cd ..
241+
242+
if [ -s checksums.txt ]; then
243+
echo "SHA256 Checksums:" > release_checksums.txt
244+
cat checksums.txt >> release_checksums.txt
245+
echo "" >> release_checksums.txt
246+
echo "MD5 Checksums:" >> release_checksums.txt
247+
cat checksums_md5.txt >> release_checksums.txt
248+
fi
249+
250+
- name: Upload checksums
251+
uses: softprops/action-gh-release@v2
252+
if: hashFiles('release_checksums.txt') != ''
253+
with:
254+
tag_name: v${{ needs.create-release.outputs.version }}
255+
files: |
256+
release_checksums.txt
257+
checksums.txt
258+
checksums_md5.txt

0 commit comments

Comments
 (0)