Skip to content

Merge branch 'dev'

Merge branch 'dev' #6

Workflow file for this run

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 dependencies (Ubuntu)
if: runner.os == 'Linux' && matrix.build == 'linux'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- 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
if [ "${{ matrix.build }}" = "windows" ]; then
cp LICENSE README.md target/${{ matrix.target }}/release/{node.exe,npm.exe,pnpm.exe,yarn.exe,snm.exe,snx.exe} archive/
7z a "${{ matrix.archive-name }}" LICENSE README.md node.exe npm.exe pnpm.exe yarn.exe snm.exe
else
cp LICENSE README.md target/${{ matrix.target }}/release/{node,npm,pnpm,yarn,snm,snx} archive/
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
run: |
for filename in ./archive/*; do
[ -e "$filename" ] || continue
echo "Uploading $filename"
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $filename)" \
--data-binary @$filename \
"${{ steps.create_release.outputs.upload_url }}?name=$(basename $filename)"
done