-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
153 additions
and
60 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
jobs: | ||
build: | ||
name: build | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
build: [linux, macos-x86_64, macos-arm, windows] | ||
include: | ||
- build: linux | ||
os: ubuntu-latest | ||
rust: nightly | ||
target: x86_64-unknown-linux-musl | ||
archive-name: snm-linux-x86.tar.gz | ||
- build: macos-x86_64 | ||
os: macos-latest | ||
rust: nightly | ||
target: x86_64-apple-darwin | ||
archive-name: snm-macos-x86.tar.gz | ||
- build: macos-arm | ||
os: macos-latest | ||
rust: nightly | ||
target: aarch64-apple-darwin | ||
archive-name: snm-macos-arm.tar.gz | ||
- build: windows | ||
os: windows-2019 | ||
rust: nightly-x86_64-msvc | ||
target: x86_64-pc-windows-msvc | ||
archive-name: snm-windows.7z | ||
fail-fast: false | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
- name: Build binary | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --verbose --release --target ${{ matrix.target }} | ||
- name: Strip binary (linux and macos) | ||
if: matrix.build == 'linux' || matrix.build == 'macos' | ||
run: | | ||
for file in snm snx node npm pnpm yarn; do | ||
strip "target/${{ matrix.target }}/release/$file" | ||
done | ||
- name: Build archive | ||
shell: bash | ||
run: | | ||
mkdir archive | ||
cp LICENSE README.md target/${{ matrix.target }}/release/{node,npm,pnpm,yarn,snm,snx} archive/ | ||
if [ "${{ matrix.build }}" = "windows" ]; then | ||
7z a "${{ matrix.archive-name }}" LICENSE README.md node.exe npm.exe pnpm.exe yarn.exe snm.exe | ||
else | ||
tar -czf ${{ matrix.archive-name }}.tar.gz -C archive LICENSE README.md node npm pnpm yarn snm snx | ||
fi | ||
- name: Upload archive | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.archive-name }} | ||
path: archive/${{ matrix.archive-name }} | ||
release: | ||
name: release | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download all archives | ||
uses: actions/download-artifact@v2 | ||
with: | ||
path: archive | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./archive/${{ matrix.archive-name }} | ||
asset_name: ${{ matrix.archive-name }} | ||
asset_content_type: application/gzip |
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