-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: improve publishing release assets (#31)
- Loading branch information
1 parent
19a90d1
commit f6c82a8
Showing
3 changed files
with
44 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
name: Build and Release | ||
|
||
name: Release | ||
on: | ||
release: | ||
types: [published] | ||
|
@@ -9,44 +8,42 @@ jobs: | |
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
architecture: [x86_64] # Since Rust doesn't natively target x86 for modern platforms, we're focusing on x86_64 | ||
include: | ||
- os: ubuntu-20.04 | ||
name: linux64 | ||
asset_name: keepsorted-linux64 | ||
- os: macos-12 | ||
name: macos | ||
asset_name: keepsorted-macos | ||
|
||
steps: | ||
# Step 1: Check out the repository | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Install Rust | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
# Step 3: Build the project | ||
- name: Build the project | ||
run: cargo build --release --all-targets | ||
|
||
# Step 4: Create a release binary file name | ||
- name: Prepare release binary | ||
run: | | ||
mkdir -p release | ||
cp target/release/keepsorted release/keepsorted-${{ matrix.os }}-${{ matrix.architecture }} | ||
# Step 5: Compress the binary using tar.gz | ||
- name: Tar the binary | ||
run: | | ||
tar -czvf keepsorted-${{ matrix.os }}-${{ matrix.architecture }}.tar.gz -C release keepsorted-${{ matrix.os }}-${{ matrix.architecture }} | ||
# Step 6: Upload the tar.gz to the GitHub release | ||
- name: Upload Release Assets | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./keepsorted-${{ matrix.os }}-${{ matrix.architecture }}.tar.gz | ||
asset_name: keepsorted-${{ matrix.os }}-${{ matrix.architecture }}.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Build | ||
run: cargo build --release --all-targets | ||
|
||
- name: Prepare Release Binary | ||
run: | | ||
mkdir -p release | ||
cp target/release/keepsorted release/${{ matrix.asset_name }} | ||
tar -czvf keepsorted-${{ matrix.asset_name }}.tar.gz -C release keepsorted-${{ matrix.asset_name }} | ||
- name: Upload Compressed Release Asset (tar.gz) | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./keepsorted-${{ matrix.asset_name }}.tar.gz | ||
asset_name: keepsorted-${{ matrix.asset_name }}.tar.gz | ||
asset_content_type: application/gzip | ||
|
||
- name: Upload Original Binary | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./release/${{ matrix.asset_name }} | ||
asset_name: keepsorted-${{ matrix.asset_name }} | ||
asset_content_type: application/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters