Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
SalOne22 committed Oct 8, 2023
1 parent ca829b7 commit eabc878
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 147 deletions.
192 changes: 48 additions & 144 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,169 +4,73 @@ on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:

permissions:
actions: read
contents: write

jobs:
build-win-binaries:
runs-on: windows-2019

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Setup cache 💾
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup nasm 🧑‍💻
uses: ilammy/setup-nasm@v1

- name: Setup rust toolchain 🦀
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-pc-windows-msvc
override: true

- name: Build rimage
shell: cmd
run: |
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
cargo build --all-features --release --target x86_64-pc-windows-msvc --verbose
- name: Get the version
id: tagName
run: echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "rimage").version')" >> "$GITHUB_OUTPUT"

- name: Build package
id: package
shell: bash
run: |
ARCHIVE_TARGET="x86_64-pc-windows-msvc"
ARCHIVE_NAME="rimage-${{ steps.tagName.outputs.tag }}-$ARCHIVE_TARGET"
ARCHIVE_FILE="${ARCHIVE_NAME}.zip"
mv LICENSE-MIT LICENSE-MIT.txt
mv LICENSE-APACHE LICENSE-APACHE.txt
7z a ${ARCHIVE_FILE} \
./target/x86_64-pc-windows-msvc/release/rimage.exe \
./CHANGELOG.md ./LICENSE-MIT.txt ./LICENSE-APACHE.txt ./README.md
echo "file=${ARCHIVE_FILE}" >> "$GITHUB_OUTPUT"
echo "name=${ARCHIVE_NAME}.zip" >> "$GITHUB_OUTPUT"
deploy:
name: deploy release
runs-on: ubuntu-latest

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.file }}
if: ${{ !github.event.repository.fork }}

build-unix-binaries:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin

runs-on: ${{ matrix.os }}
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-pc-windows-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Setup cache 💾
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup nasm 🧑‍💻
uses: ilammy/setup-nasm@v1
- name: Get the rimage version 🪶
id: rimage-meta
run:
echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "rimage").version')"
>> "$GITHUB_OUTPUT"

- name: Setup rust toolchain 🦀
uses: actions-rs/toolchain@v1
- name: Retrieve ${{ matrix.target }} binary 🔃
uses: dawidd6/action-download-artifact@v2
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
workflow: rimage.yml
commit: ${{ env.GITHUB_SHA }}
name: rimage binary (${{ matrix.target }})
path: target

- name: Build rimage
run: cargo build --all-features --release --target ${{ matrix.target }} --verbose

- name: Strip binary
- name: Build archives 🏗
working-directory: target
run: |
strip target/${{ matrix.target }}/release/rimage
- name: Get the version
id: tagName
run: echo "version=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "rimage").version')" >> "$GITHUB_OUTPUT"

- name: Build package
id: package
run: |
ARCHIVE_TARGET=${{ matrix.target }}
ARCHIVE_NAME="rimage-${{ steps.tagName.outputs.tag }}-$ARCHIVE_TARGET"
ARCHIVE_FILE="${ARCHIVE_NAME}.tar.gz"
mkdir "/tmp/${ARCHIVE_NAME}"
cp README.md CHANGELOG.md LICENSE-MIT LICENSE-APACHE \
target/${{ matrix.target }}/release/rimage \
/tmp/${ARCHIVE_NAME}
tar -czf ${PWD}/${ARCHIVE_FILE} -C /tmp/ ${ARCHIVE_NAME}
echo "file=${ARCHIVE_FILE}" >> "$GITHUB_OUTPUT"
echo "name=${ARCHIVE_NAME}.tar.gz" >> "$GITHUB_OUTPUT"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.file }}

deploy:
needs: [build-win-binaries, build-unix-binaries]

runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Get version and release description
id: tagName
run: |
VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "rimage").version')
tail -n +5 CHANGELOG.md | sed -e '/## \[v/,$d' > CHANGELOG.txt
echo "tag=VERSION" >> "$GITHUB_OUTPUT"
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./binaries

- name: Create a release
ARCHIVE_NAME="rimage-${{ steps.rimage-meta.outputs.version }}-${{ matrix.target }}"
mkdir "$ARCHIVE_NAME"
cp ../CHANGELOG.md ../README.md "$ARCHIVE_NAME"
case '${{ matrix.target }}' in
*-windows-*)
cp ../LICENSE "$ARCHIVE_NAME/LICENSE.txt"
cp rimage.exe "$ARCHIVE_NAME"
zip "${ARCHIVE_NAME}.zip" "$ARCHIVE_NAME"/*;;
*)
cp ../LICENSE "$ARCHIVE_NAME"
cp rimage "$ARCHIVE_NAME"
tar -vczf "${ARCHIVE_NAME}.tar.gz" "$ARCHIVE_NAME"/*;;
esac
- name: Create release notes 📑
run: tail -n +5 CHANGELOG.md | sed -e '/## \[v/,$d' > RELEASE_NOTES.txt

- name: Create release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.tagName.outputs.tag }}
body_path: CHANGELOG.txt
name: v${{ steps.rimage-meta.outputs.version }}
body_path: RELEASE_NOTES.txt
files: |
./binaries/**/*.zip
./binaries/**/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
target/*.zip
target/*.tar.gz
6 changes: 3 additions & 3 deletions .github/workflows/rimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ jobs:
args: --all-features --release

- name: Test 🧪
if: matrix.target != 'aarch64-apple-darwin' || matrix.target != 'aarch64-unknown-linux-gnu'
if: matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'x86_64-apple-darwin'
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --release

- name: Upload CLI binary as artifact
- name: Upload CLI binary as artifact 💾
uses: actions/upload-artifact@v3
with:
name: Rimage binary (${{ matrix.target }})
name: rimage binary (${{ matrix.target }})
path: |
target/${{ env.CARGO_BUILD_TARGET }}/release/rimage
target/${{ env.CARGO_BUILD_TARGET }}/release/rimage.exe
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To get started with contributing, you'll need to:
2. Clone your fork locally.
3. Install Rust and Cargo (if you haven't already).
4. Install cmake and nasm for AVIF and JPEG XL development.
> Note: On x86_64 macos, you need to install `jpeg-xl` library
5. Run `cargo build` to ensure everything builds properly.
> Note: On Windows, use a Visual Studio build environment like Developer PowerShell for VS 2019/2022.
Expand Down

0 comments on commit eabc878

Please sign in to comment.