Merge branch 'master' into 0.6.0-scripting-dev #71
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
on: | |
push: | |
tags: | |
- v* | |
name: Release | |
jobs: | |
create-release: | |
name: Create release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/44937/highlight/true#M5978 | |
- name: Get the version | |
id: get_version | |
run: | | |
set -x | |
version=${GITHUB_REF/refs\/tags\//} | |
echo VERSION=$version >> $GITHUB_ENV | |
# remove the leading "v" for subsequent usage | |
version=${version/v/} | |
# check if this is a "preview" release and should be marked as "prerelease" in GitHub releases | |
if [[ $version == *"preview"* ]]; then | |
echo PRERELEASE=true >> $GITHUB_ENV | |
else | |
# check that the version in Cargo.toml is equal to the tag | |
grep -q "^version = \"${version}\"" Cargo.toml || (echo "$(tput setaf 1)Tag version did NOT match version in Cargo.toml" && false) | |
echo PRERELEASE=false >> $GITHUB_ENV | |
fi | |
shell: bash | |
- name: Create GitHub release | |
id: release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: ${{ env.VERSION }} | |
prerelease: ${{ env.PRERELEASE }} | |
- name: Save artifacts | |
run: | | |
mkdir artifacts | |
echo "${{ steps.release.outputs.upload_url }}" | tee artifacts/release-upload-url | |
echo $VERSION | tee artifacts/release-version | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifacts | |
path: artifacts | |
release: | |
name: Build and Upload | |
needs: ['create-release'] | |
strategy: | |
matrix: | |
binary: ["pewpew", "pewpew-config-updater"] | |
build: ["linux", "arm-v7", "aarch64", "macos-x86", "macos-aarch64", "windows"] | |
include: | |
- binary: "pewpew" | |
build_param: "--bin" | |
- binary: "pewpew-config-updater" | |
build_param: "-p" | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
cross: false | |
- build: arm-v7 | |
os: ubuntu-latest | |
target: armv7-unknown-linux-musleabihf | |
linker: gcc-arm-linux-gnueabihf | |
cross: true | |
- build: aarch64 | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
linker: gcc-aarch64-linux-gnu | |
cross: true | |
- build: macos-x86 | |
os: macos-latest | |
cross: false | |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/about-larger-runners | |
# macos-latest-xlarge or macos-13-xlarge are running on arm64 (m1) | |
- build: macos-aarch64 | |
os: macos-latest-xlarge | |
cross: false | |
- build: windows | |
os: windows-latest | |
cross: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Get upload data | |
id: upload_data | |
shell: bash | |
run: | | |
release_upload_url="$(cat artifacts/release-upload-url)" | |
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV | |
release_version="$(cat artifacts/release-version)" | |
echo "VERSION=$release_version" >> $GITHUB_ENV | |
- name: Set Cargo.toml version | |
id: set_cargo_version | |
shell: bash | |
run: | | |
# remove the leading "v" for subsequent usage | |
version=${VERSION/v/} | |
# replace the version value in Cargo.toml with the tag version (so we don't need to create extraneous commits for every preview version) | |
cp Cargo.toml Cargo2.toml | |
sed "0,/^version = \".*\"/s//version = \"$version\"/" Cargo2.toml > Cargo.toml | |
- name: Install Linker | |
if: matrix.cross | |
run: | | |
sudo apt update | |
sudo apt install ${{ matrix.linker }} | |
- name: Build for non-Linux # Windows and MacOS | |
uses: actions-rs/toolchain@v1 | |
if: matrix.os != 'ubuntu-latest' | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- uses: actions-rs/cargo@v1 | |
if: matrix.os != 'ubuntu-latest' | |
with: | |
command: build | |
args: -q --release ${{ matrix.build_param }} ${{ matrix.binary }} | |
# https://github.com/actions-rs/cargo#cross-compilation | |
- name: Build with cross # ARM builds | |
uses: actions-rs/toolchain@v1 | |
if: matrix.cross | |
with: | |
profile: minimal | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- uses: actions-rs/cargo@v1 | |
if: matrix.cross | |
with: | |
use-cross: true | |
command: build | |
args: -q --release ${{ matrix.build_param }} ${{ matrix.binary }} --target ${{ matrix.target }} | |
- name: Build for Linux | |
uses: ./.github/actions/linux-x86_64-musl/ | |
if: matrix.build == 'linux' | |
with: | |
args: cargo build -q --release ${{ matrix.build_param }} ${{ matrix.binary }} --target x86_64-unknown-linux-musl | |
- name: Compress for Linux/Arm | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
TARGET=$(echo "${{ matrix.target }}" | sed -e "s/-musl.*//" -e "s/-unknown//") | |
asset_name="${{ matrix.binary }}-$VERSION-$TARGET.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./target/${{ matrix.target }}/release/ -cJf $asset_name ${{ matrix.binary }} | |
- name: Compress for Windows | |
if: matrix.os == 'windows-latest' | |
shell: bash | |
run: | | |
asset_name="${{ matrix.binary }}-$VERSION-x86_64-windows.zip" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
7z a -mm=Deflate64 -mfb=258 -mpass=15 $asset_name ./target/release/${{ matrix.binary }}.exe | |
- name: Compress for macOS x86 | |
if: matrix.os == 'macos-latest' | |
run: | | |
asset_name="${{ matrix.binary }}-$VERSION-x86_64-apple-darwin.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name ${{ matrix.binary }} | |
- name: Compress for macOS aarch64 | |
if: matrix.os == 'macos-latest-xlarge' | |
run: | | |
asset_name="${{ matrix.binary }}-$VERSION-aarch64-apple-darwin.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./target/release/ -cJf $asset_name ${{ matrix.binary }} | |
- name: Upload release asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ env.RELEASE_UPLOAD_URL }} | |
asset_path: ${{ env.ASSET_NAME }} | |
asset_name: ${{ env.ASSET_NAME }} | |
asset_content_type: application/octet-stream | |
wasm-release-config: | |
name: Wasm Pack and Upload Node Release | |
needs: ['create-release'] | |
strategy: | |
matrix: | |
wasm-dirctory: ["config-wasm"] | |
include: | |
- wasm-dirctory: config-wasm | |
file-prefix: config | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./lib/${{ matrix.wasm-dirctory }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Get upload data | |
id: upload_data | |
shell: bash | |
run: | | |
release_upload_url="$(cat artifacts/release-upload-url)" | |
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV | |
release_version="$(cat artifacts/release-version)" | |
echo "VERSION=$release_version" >> $GITHUB_ENV | |
- name: Set Cargo.toml version | |
id: set_cargo_version | |
shell: bash | |
run: | | |
# remove the leading "v" for subsequent usage | |
version=${VERSION/v/} | |
# replace the version value in Cargo.toml with the tag version (so we don't need to create extraneous commits for every preview version) | |
cp Cargo.toml Cargo2.toml | |
sed "0,/^version = \".*\"/s//version = \"$version\"/" Cargo2.toml > Cargo.toml | |
echo "version = $version" | |
echo "Cargo $(grep "^version =" Cargo.toml )" | |
working-directory: ${{env.working-directory}} | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Create the Web Assembly | |
id: wasm_pack | |
run: | | |
set -x | |
# install wasm-pack | |
mkdir ~/bin | |
PATH=$PATH:~/bin | |
curl -sSL https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz \ | |
| tar -xz --strip-components=1 -C ~/bin --no-anchored wasm-pack | |
wasm-pack build --release -t nodejs --scope fs | |
working-directory: ${{env.working-directory}} | |
shell: bash | |
- name: Compress for Linux | |
run: | | |
asset_name="pewpew-$VERSION-${{ matrix.wasm-dirctory }}.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./ -cJf $asset_name package.json ${{ matrix.file-prefix }}* | |
working-directory: ${{env.working-directory}}/pkg/ | |
- name: Upload release asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ env.RELEASE_UPLOAD_URL }} | |
asset_path: ${{env.working-directory}}/pkg/${{ env.ASSET_NAME }} | |
asset_name: ${{ env.ASSET_NAME }} | |
asset_content_type: application/octet-stream | |
# The hdr-histogram-wasm and config-gen need to be build with bundler rather than nodejs | |
wasm-release-histogram: | |
name: Wasm Pack and Upload Bundler Release | |
needs: ['create-release'] | |
strategy: | |
matrix: | |
wasm-dirctory: ["hdr-histogram-wasm", "config-gen"] | |
include: | |
- wasm-dirctory: hdr-histogram-wasm | |
file-prefix: hdr | |
- wasm-dirctory: config-gen | |
file-prefix: config | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./lib/${{ matrix.wasm-dirctory }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifacts | |
path: artifacts | |
- name: Get upload data | |
id: upload_data | |
shell: bash | |
run: | | |
release_upload_url="$(cat artifacts/release-upload-url)" | |
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV | |
release_version="$(cat artifacts/release-version)" | |
echo "VERSION=$release_version" >> $GITHUB_ENV | |
- name: Set Cargo.toml version | |
id: set_cargo_version | |
shell: bash | |
run: | | |
# remove the leading "v" for subsequent usage | |
version=${VERSION/v/} | |
# replace the version value in Cargo.toml with the tag version (so we don't need to create extraneous commits for every preview version) | |
cp Cargo.toml Cargo2.toml | |
sed "0,/^version = \".*\"/s//version = \"$version\"/" Cargo2.toml > Cargo.toml | |
echo "version = $version" | |
echo "Cargo $(grep "^version =" Cargo.toml )" | |
working-directory: ${{env.working-directory}} | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Create the Web Assembly | |
id: wasm_pack | |
run: | | |
set -x | |
# install wasm-pack | |
mkdir ~/bin | |
PATH=$PATH:~/bin | |
curl -sSL https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz \ | |
| tar -xz --strip-components=1 -C ~/bin --no-anchored wasm-pack | |
wasm-pack build --release -t bundler --scope fs | |
working-directory: ${{env.working-directory}} | |
shell: bash | |
- name: Compress for Linux | |
run: | | |
asset_name="pewpew-$VERSION-${{ matrix.wasm-dirctory }}.tar.xz" | |
echo "ASSET_NAME=$asset_name" >> $GITHUB_ENV | |
XZ_OPT=-9 tar -C ./ -cJf $asset_name package.json ${{ matrix.file-prefix }}* | |
working-directory: ${{env.working-directory}}/pkg/ | |
- name: Upload release asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ env.RELEASE_UPLOAD_URL }} | |
asset_path: ${{env.working-directory}}/pkg/${{ env.ASSET_NAME }} | |
asset_name: ${{ env.ASSET_NAME }} | |
asset_content_type: application/octet-stream |