Merge pull request #31 from ottomated/updates #98
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: Build | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Get version | |
id: get_version | |
run: echo "version=$(grep "version" Cargo.toml | head -n1 | cut -d '"' -f2)" >> $GITHUB_OUTPUT | |
- name: Compare version to NPM | |
run: | | |
NPM_VERSION=$(npm view create-o7-app version) | |
MY_VERSION=${{ steps.get_version.outputs.version }} | |
if [ "$NPM_VERSION" == "$MY_VERSION" ]; then | |
echo "NPM version is the same as the version in Cargo.toml, exiting" | |
exit 1 | |
fi | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
targets: x86_64-unknown-linux-musl,x86_64-pc-windows-gnu,i686-pc-windows-gnu,x86_64-apple-darwin,aarch64-apple-darwin | |
- name: Install pnpm | |
run: npm i -g pnpm | |
- name: Test | |
run: cargo test | |
- name: Install MinGW | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gcc-mingw-w64-x86-64 gcc-mingw-w64-i686 | |
- name: Cache OSXCross | |
id: cache-osxcross | |
uses: actions/cache@v4 | |
with: | |
path: osxcross | |
key: ${{ runner.os }}-osxcross-11.3 | |
save-always: true | |
- name: Install OSXCross | |
if: steps.cache-osxcross.outputs.cache-hit != 'true' | |
run: | | |
git clone https://github.com/tpoechtrager/osxcross | |
cd osxcross | |
sudo tools/get_dependencies.sh | |
wget -nc https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz | |
mv MacOSX11.3.sdk.tar.xz tarballs/ | |
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh | |
- name: Build MacOS | |
run: | | |
export PATH="$(pwd)/osxcross/target/bin:$PATH" | |
export LIBZ_SYS_STATIC=1 | |
export CC=o64-clang | |
export CXX=o64-clang++ | |
cargo build --release --target x86_64-apple-darwin | |
cargo build --release --target aarch64-apple-darwin | |
- name: Build Linux | |
run: cargo build --release --target x86_64-unknown-linux-musl | |
- name: Build Windows | |
run: cargo build --release --target x86_64-pc-windows-gnu | |
- name: Build Windows 32 | |
run: cargo build --release --target i686-pc-windows-gnu | |
- name: Copy Artifacts | |
run: | | |
mkdir artifacts | |
mv target/x86_64-unknown-linux-musl/release/create-o7-app artifacts/create-o7-app-linux | |
mv target/x86_64-pc-windows-gnu/release/create-o7-app.exe artifacts/create-o7-app-win64.exe | |
mv target/i686-pc-windows-gnu/release/create-o7-app.exe artifacts/create-o7-app-win32.exe | |
mv target/x86_64-apple-darwin/release/create-o7-app artifacts/create-o7-app-macos | |
mv target/aarch64-apple-darwin/release/create-o7-app artifacts/create-o7-app-macos-arm64 | |
mkdir -p compressed/artifacts | |
for file in artifacts/*; do tar -czvf "compressed/$file.tar.gz" "$file"; done | |
- uses: step-security/wait-for-secrets@v1 | |
id: wait-for-secrets | |
with: | |
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | |
secrets: | | |
OTP: | |
name: 'NPM OTP' | |
description: 'OTP from authenticator app' | |
- name: Release Binaries | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.get_version.outputs.version }} | |
files: compressed/artifacts/* | |
- name: Publish NPM Package | |
run: | | |
cd pkg | |
cp ../README.md . | |
jq '.version = "${{ steps.get_version.outputs.version }}"' package.json > tmp && mv tmp package.json | |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | |
npm publish --otp ${{ steps.wait-for-secrets.outputs.OTP }} |