Skip to content

Commit

Permalink
feat: add new workflow to cross-compile wws (#23)
Browse files Browse the repository at this point in the history
* feat: add new workflow to cross-compile wws

* feat: install missing components with rustup

* fix: configure the release action trigger to run on tags

* fix: install target platforms properly with rustup

* fix: set the proper matrix to build all desired flavors

* fix: skip windows on aarch64 due to the lack of cross official images

* fix: install musl-tools for linux builds

* fix: remove quotes when using values in if conditional

* fix: set the right format for conditionals with strings in the release workflow

* fix: use sudo with apt-get

* fix: ensure we are using bash on windows too

* fix: create flat tar.gz files. Set the right file name

* feat: enables the windows arm64 build

* fix: set the -C flag properly when compressing the output files

* chore: try to avoid using cross if not required

* fix: continue using cross for linux aarch64

* feat: run only when tags are pushed and rename the file

* fix: remove the artifact retention time that was used for testing
  • Loading branch information
Angelmmiguel authored Nov 14, 2022
1 parent 14a624f commit 383e0c4
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Build artifacts

on:
push:
branches: [ main ]
tags:
- "[0-9]+.[0-9]+.[0-9]+"
# TODO: uncomment for testing. This will run by default only when a new tag is created
# pull_request:
# branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Caching
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Test
run: cargo test
build:
strategy:
matrix:
build: [linux, windows, macos]
arch: [x86_64, aarch64]
include:
- build: linux
arch: x86_64
os: ubuntu-latest
platform: unknown-linux-musl
cross: false
name: linux-musl
- build: linux
arch: aarch64
os: ubuntu-latest
platform: unknown-linux-musl
cross: true
name: linux-musl
- build: windows
arch: x86_64
os: windows-latest
platform: pc-windows-msvc
cross: false
name: pc-windows
- build: windows
arch: aarch64
os: windows-latest
platform: pc-windows-msvc
cross: false
name: pc-windows
- build: macos
arch: x86_64
os: macos-latest
platform: apple-darwin
cross: false
name: macos-darwin
- build: macos
arch: aarch64
os: macos-latest
platform: apple-darwin
cross: false
name: macos-darwin
runs-on: ${{ matrix.os }}
env:
# We use cross for arm builds
CARGO: cargo
steps:
- uses: actions/checkout@v3
- name: Install cross
if: matrix.cross == true
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
- name: Install target
if: matrix.cross == false
run: rustup target add ${{ matrix.arch }}-${{ matrix.platform }}
- name: Install deps
if: ${{ matrix.build == 'linux' }}
run: |
sudo apt-get update
sudo apt-get install musl-tools
- name: Build
run: ${{env.CARGO}} build --verbose --release --target=${{ matrix.arch }}-${{ matrix.platform }}
- name: Tarball
shell: bash
run: |
mkdir out
cp {README.md,LICENSE} out
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp "target/${{ matrix.arch }}-${{ matrix.platform }}/release/wws.exe" ./out
else
cp "target/${{ matrix.arch }}-${{ matrix.platform }}/release/wws" ./out
fi
tar czvf "wws-${{ matrix.name }}-${{ matrix.arch }}.tar.gz" -C ./out .
echo "TARBALL=wws-${{ matrix.name }}-${{ matrix.arch }}.tar.gz" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: wws-${{ matrix.name }}-${{ matrix.arch }}.tar.gz
path: ${{ env.TARBALL }}

0 comments on commit 383e0c4

Please sign in to comment.