Build more release binaries (#233)

* Build more release binaries

Include a static Linux binary with musl and a macOS build.  Also add
readme, license and changelog to the release archives.

Fixes GH-134

* Merge windows and linux builds

* Test musl and darwin targets

* Fix matrix exclude key
This commit is contained in:
lunaryorn 2020-06-02 15:35:49 +02:00 committed by GitHub
parent 974dfcfeac
commit f5d8aa0249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 92 deletions

View file

@ -7,20 +7,22 @@ on:
jobs: jobs:
create-binaries-windows: create-binaries:
strategy: strategy:
matrix: matrix:
conf: os: [ubuntu-latest, macOS-latest, windows-latest]
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
include: include:
- conf: x86_64-pc-windows-msvc - os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macOS-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
- conf: i686-pc-windows-msvc - os: windows-latest
target: i686-pc-windows-msvc target: i686-pc-windows-msvc
runs-on: windows-latest runs-on: '${{ matrix.os }}'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -33,10 +35,18 @@ jobs:
target: ${{ matrix.target }} target: ${{ matrix.target }}
override: true override: true
- name: Install musl
run: sudo apt-get install musl-tools
if: contains(matrix.target, 'linux-musl')
- name: Build oxipng - name: Build oxipng
run: | run: |
cargo build --release --target ${{ matrix.target }} cargo build --release --target ${{ matrix.target }}
- name: Strip binary
run: strip 'target/${{ matrix.target }}/release/oxipng'
if: "!contains(matrix.target, 'windows')"
- name: Get the version - name: Get the version
shell: bash shell: bash
id: tagName id: tagName
@ -44,22 +54,35 @@ jobs:
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
echo "::set-output name=tag::$VERSION" echo "::set-output name=tag::$VERSION"
- name: Create zip - name: Build package
id: package
shell: bash
run: | run: |
$OXIPNG_PATH="$Env:GITHUB_WORKSPACE\target\${{ matrix.target }}\release" ARCHIVE_NAME="oxipng-${{ steps.tagName.outputs.tag }}-${{ matrix.target }}"
strip "$OXIPNG_PATH\oxipng.exe" if [[ '${{ matrix.target }}' == *windows* ]]; then
7z a oxipng-${{ steps.tagName.outputs.tag }}-${{ matrix.target }}.zip ` ARCHIVE_FILE="${ARCHIVE_NAME}.zip"
"$OXIPNG_PATH\oxipng.exe" mv LICENSE LICENSE.txt
7z a "${ARCHIVE_FILE}" "./target/${{ matrix.target }}/release/oxipng.exe" ./CHANGELOG.md ./LICENSE.txt ./README.md
echo ::set-output "name=file::${ARCHIVE_FILE}"
echo ::set-output "name=name::${ARCHIVE_NAME}.zip"
else
ARCHIVE_FILE="${ARCHIVE_NAME}.tar.gz"
mkdir "/tmp/${ARCHIVE_NAME}"
cp README.md CHANGELOG.md LICENSE "target/${{ matrix.target }}/release/oxipng" "/tmp/${ARCHIVE_NAME}"
tar -czf "${PWD}/${ARCHIVE_FILE}" -C /tmp/ "${ARCHIVE_NAME}"
echo ::set-output "name=file::${ARCHIVE_FILE}"
echo ::set-output "name=name::${ARCHIVE_NAME}.tar.gz"
fi
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: oxipng-${{ steps.tagName.outputs.tag }}-${{ matrix.target }} name: ${{ steps.package.outputs.name }}
path: oxipng-${{ steps.tagName.outputs.tag }}-${{ matrix.target }}.zip path: ${{ steps.package.outputs.file }}
deploy: deploy:
needs: create-binaries-windows needs: create-binaries
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -73,15 +96,10 @@ jobs:
tail -n +2 CHANGELOG.md | sed -e '/^$/,$d' > CHANGELOG.txt tail -n +2 CHANGELOG.md | sed -e '/^$/,$d' > CHANGELOG.txt
echo "::set-output name=tag::$VERSION" echo "::set-output name=tag::$VERSION"
- name: Download x86_64 Windows artifact - name: Download artifacts
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
name: oxipng-${{ steps.tagName.outputs.tag }}-x86_64-pc-windows-msvc path: ./binaries
- name: Download i686 Windows artifact
uses: actions/download-artifact@v2
with:
name: oxipng-${{ steps.tagName.outputs.tag }}-i686-pc-windows-msvc
- name: Create a release - name: Create a release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
@ -89,7 +107,7 @@ jobs:
name: v${{ steps.tagName.outputs.tag }} name: v${{ steps.tagName.outputs.tag }}
body_path: CHANGELOG.txt body_path: CHANGELOG.txt
files: | files: |
oxipng-${{ steps.tagName.outputs.tag }}-x86_64-pc-windows-msvc.zip ./binaries/**/*.zip
oxipng-${{ steps.tagName.outputs.tag }}-i686-pc-windows-msvc.zip ./binaries/**/*.tar.gz
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View file

@ -9,26 +9,48 @@ on:
- master - master
jobs: jobs:
build-test-unix: test:
runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
conf: target:
- minimum-stable - x86_64-unknown-linux-gnu
- latest-stable - x86_64-unknown-linux-musl
- latest-beta - x86_64-pc-windows-msvc
- latest-nightly - x86_64-apple-darwin
toolchain:
# Minimum stable
- "1.41.0"
- stable
- beta
- nightly
include: include:
- conf: minimum-stable - target: x86_64-unknown-linux-gnu
toolchain: 1.41.0 os: ubuntu-latest
- conf: latest-stable - target: x86_64-unknown-linux-musl
toolchain: stable os: ubuntu-latest
- conf: latest-beta - target: x86_64-pc-windows-msvc
toolchain: beta os: windows-latest
- conf: latest-nightly - target: x86_64-apple-darwin
toolchain: nightly os: macOS-latest
exclude:
- target: x86_64-pc-windows-msvc
toolchain: beta
- target: x86_64-pc-windows-msvc
toolchain: nightly
- target: x86_64-apple-darwin
toolchain: beta
- target: x86_64-apple-darwin
toolchain: nightly
- target: x86_64-unknown-linux-musl
toolchain: beta
- target: x86_64-unknown-linux-musl
toolchain: nightly
runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install musl tools
run: sudo apt-get install musl-tools
if: "contains(matrix.target, 'musl')"
- name: Install ${{ matrix.toolchain }} - name: Install ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -40,9 +62,9 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ~/.cargo/registry/cache path: ~/.cargo/registry/cache
key: ${{ runner.os }}-${{ matrix.conf }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} key: ${{ matrix.target }}-${{ matrix.toolchain }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-${{ matrix.conf }}-cargo-registry- ${{ matrix.target }}-${{ matrix.toolchain }}-cargo-registry-
- name: Run rustfmt - name: Run rustfmt
if: matrix.toolchain == 'stable' if: matrix.toolchain == 'stable'
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
@ -68,54 +90,3 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
args: --no-default-features -- -D warnings args: --no-default-features -- -D warnings
build-test-windows:
runs-on: windows-latest
strategy:
matrix:
conf:
- minimum-stable
- latest-stable
include:
- conf: minimum-stable
toolchain: 1.41.0
- conf: latest-stable
toolchain: stable
steps:
- uses: actions/checkout@v2
- name: Install ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry/cache
key: ${{ runner.os }}-${{ matrix.conf }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.conf }}-cargo-registry-
- name: Run rustfmt
if: matrix.toolchain == 'stable'
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Run clippy
if: matrix.toolchain == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- -D warnings
- name: Run tests
run: cargo test
- name: Build docs
run: cargo doc --no-deps
- name: Check no default features
if: matrix.toolchain == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --no-default-features -- -D warnings