0.0.1-99 #55
Workflow file for this run
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
name: Publish GitHub release | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-test: | |
strategy: | |
matrix: | |
include: | |
# Linux targets | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
# target: x86_64-unknown-linux-gnu | |
# - os: ubuntu-latest | |
# target: i686-unknown-linux-gnu | |
# - os: ubuntu-latest | |
# target: aarch64-unknown-linux-gnu | |
# Windows targets | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: windows-latest | |
target: i686-pc-windows-msvc | |
# macOS targets | |
- os: macos-14 | |
target: aarch64-apple-darwin | |
- os: macos-13 | |
target: x86_64-apple-darwin | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Install Dependencies | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y openssl pkg-config libssl-dev musl-tools | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Run Tests | |
run: cargo test | |
env: | |
RUST_BACKTRACE: full | |
- name: Build Binary | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --verbose --release --target ${{ matrix.target }} | |
- name: Strip Binary (Linux and macOS only) | |
if: matrix.os != 'windows-latest' | |
run: | | |
for file in snm node npm npx pnpm pnpx yarn; do | |
strip "target/${{ matrix.target }}/release/$file" | |
done | |
- name: Create Archive | |
shell: bash | |
run: | | |
mkdir archive | |
cp LICENSE README.md target/${{ matrix.target }}/release/{node,npm,npx,pnpm,pnpx,snm,yarn} archive/ | |
tar -czf ${{ matrix.target }}.tar.gz -C archive LICENSE README.md node npm npx pnpm pnpx snm yarn | |
ls -l | |
- name: Calculate SHA256 Checksum | |
run: | | |
echo "Calculating SHA256 for ${{ matrix.target }}.tar.gz..." | |
if [ "${{ matrix.os }}" == "windows-latest" ]; then | |
certutil -hashfile "${{ matrix.target }}.tar.gz" SHA256 > "${{ matrix.target }}.sha256" | |
else | |
shasum -a 256 ${{ matrix.target }}.tar.gz | tee ${{ matrix.target }}.sha256 | |
fi | |
cat ${{ matrix.target }}.sha256 | |
shell: bash | |
- name: Upload Artifacts tar.gz | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }} | |
path: ${{ matrix.target }}.tar.gz | |
- name: Upload Artifacts sha256 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}.sha256 | |
path: ${{ matrix.target }}.sha256 | |
publish-github-release: | |
name: Publish To Github Release | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
steps: | |
- uses: actions/download-artifact@v4 | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
name: ${{ github.ref_name }} | |
files: | | |
**/*.tar.gz | |
**/*.sha256 | |
generate-homebrew-formula: | |
permissions: | |
contents: write | |
name: Generate And Upload Homebrew snm.rb File | |
runs-on: ubuntu-latest | |
needs: publish-github-release | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: . | |
- name: Display structure of downloaded files | |
run: | | |
ls -R | |
cd x86_64-apple-darwin.sha256 | |
cat x86_64-apple-darwin.sha256 | |
- name: Generate Homebrew Formula | |
run: | | |
VERSION=${{ github.ref_name }} | |
SHA256_INTEL=$(cat x86_64-apple-darwin.sha256/x86_64-apple-darwin.sha256 | awk '{print $1}') | |
SHA256_ARM=$(cat aarch64-apple-darwin.sha256/aarch64-apple-darwin.sha256 | awk '{print $1}') | |
cat <<EOF > snm.rb | |
class Snm < Formula | |
desc "snm = corepack + fnm + ni ." | |
homepage "https://github.com/sheinsight/snm" | |
version "$VERSION" | |
if Hardware::CPU.intel? | |
url "https://github.com/sheinsight/snm/releases/download/$VERSION/x86_64-apple-darwin.tar.gz" | |
sha256 "$SHA256_INTEL" | |
elsif Hardware::CPU.arm? | |
url "https://github.com/sheinsight/snm/releases/download/$VERSION/aarch64-apple-darwin.tar.gz" | |
sha256 "$SHA256_ARM" | |
end | |
license "MIT" | |
def install | |
bin.install "snm", "pnpx", "pnpm", "npx", "npm", "yarn", "node" | |
end | |
test do | |
system "#{bin}/snm", "--version" | |
end | |
end | |
EOF | |
- name: Upload artifacts snm.rb | |
uses: actions/upload-artifact@v4 | |
with: | |
name: snm.rb | |
path: snm.rb | |
create-pull-request: | |
name: Create Homebrew Pull Request | |
runs-on: ubuntu-latest | |
needs: generate-homebrew-formula | |
steps: | |
- name: Checkout repository B | |
uses: actions/checkout@v3 | |
with: | |
repository: sheinsight/homebrew-shined | |
token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} | |
path: . | |
- uses: actions/download-artifact@v4 | |
with: | |
name: snm.rb | |
path: . | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }} | |
commit-message: Auto-generated PR from repository A | |
title: 'update snm to version ${{ github.ref_name }}' | |
body: | | |
This pull request is auto-generated by GitHub Actions from repository A. | |
add-paths: snm.rb | |
branch: update-snm-rb-${{ github.ref_name }} | |
base: main | |