Thanks to visit codestin.com
Credit goes to github.com

Skip to content

release: v2.0.0

release: v2.0.0 #1

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
npm_pkg: diamondscaffold-darwin-arm64
binary: diamonds
- target: x86_64-apple-darwin
os: macos-latest
npm_pkg: diamondscaffold-darwin-x64
binary: diamonds
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
npm_pkg: diamondscaffold-linux-x64
binary: diamonds
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
npm_pkg: diamondscaffold-linux-arm64
binary: diamonds
- target: x86_64-pc-windows-msvc
os: windows-latest
npm_pkg: diamondscaffold-win32-x64
binary: diamonds.exe
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build release binary
working-directory: v2
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Copy binary to npm package
shell: bash
run: |
cp v2/target/${{ matrix.target }}/release/${{ matrix.binary }} npm/${{ matrix.npm_pkg }}/bin/${{ matrix.binary }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.npm_pkg }}
path: npm/${{ matrix.npm_pkg }}
publish-npm:
name: Publish to npm
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Copy binaries into npm packages
run: |
for pkg in diamondscaffold-darwin-arm64 diamondscaffold-darwin-x64 diamondscaffold-linux-x64 diamondscaffold-linux-arm64 diamondscaffold-win32-x64; do
cp -r artifacts/$pkg/* npm/$pkg/
done
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Update all package.json versions
for dir in npm/diamondscaffold npm/diamondscaffold-darwin-arm64 npm/diamondscaffold-darwin-x64 npm/diamondscaffold-linux-x64 npm/diamondscaffold-linux-arm64 npm/diamondscaffold-win32-x64; do
cd $dir
npm version $VERSION --no-git-tag-version --allow-same-version
cd ${{ github.workspace }}
done
# Update optionalDependencies versions in main package
cd npm/diamondscaffold
node -e "
const pkg = require('./package.json');
for (const dep of Object.keys(pkg.optionalDependencies)) {
pkg.optionalDependencies[dep] = '$VERSION';
}
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Publish platform packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
for pkg in diamondscaffold-darwin-arm64 diamondscaffold-darwin-x64 diamondscaffold-linux-x64 diamondscaffold-linux-arm64 diamondscaffold-win32-x64; do
cd npm/$pkg
npm publish --access public || true
cd ${{ github.workspace }}
done
- name: Publish main package
working-directory: npm/diamondscaffold
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
publish-crate:
name: Publish to crates.io
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
working-directory: v2
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}
run: cargo publish --allow-dirty
github-release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Package release assets
run: |
mkdir -p release
for pkg in diamondscaffold-darwin-arm64 diamondscaffold-darwin-x64 diamondscaffold-linux-x64 diamondscaffold-linux-arm64 diamondscaffold-win32-x64; do
if [ -f "artifacts/$pkg/bin/diamonds.exe" ]; then
cp "artifacts/$pkg/bin/diamonds.exe" "release/$pkg.exe"
else
cp "artifacts/$pkg/bin/diamonds" "release/$pkg"
chmod +x "release/$pkg"
fi
done
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true