This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
new-release #91
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: Handle Release | |
on: | |
release: | |
types: [created] | |
repository_dispatch: | |
types: [new-release] | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
metadata: | |
name: Generate Matrix | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Make matrix | |
id: generate | |
run: python .github-deps/generate-matrix.py rust/rust-toolchain.toml | |
outputs: | |
matrix: ${{ steps.generate.outputs.matrix }} | |
build: | |
name: Build | |
runs-on: windows-latest | |
needs: metadata | |
strategy: | |
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }} | |
steps: | |
- name: Get latest release | |
id: latest_release | |
uses: kaliber5/action-get-release@v1 | |
with: | |
token: ${{ github.token }} | |
latest: true | |
- name: Get latest IM release | |
id: latest_release_im | |
uses: kaliber5/action-get-release@v1 | |
with: | |
token: ${{ github.token }} | |
latest: true | |
repo: Android-ImageMagick7 | |
- name: Checkout Android ImageMagick | |
uses: actions/checkout@v2 | |
with: | |
repository: molotovcherry/Android-ImageMagick7 | |
ref: ${{ steps.latest_release_im.outputs.tag_name }} | |
- name: Checkout KMagick | |
if: github.event_name != 'workflow_dispatch' | |
uses: actions/checkout@v2 | |
with: | |
path: kmagick-rs | |
ref: ${{ steps.latest_release.outputs.tag_name }} | |
- name: Checkout KMagick | |
if: github.event_name == 'workflow_dispatch' | |
uses: actions/checkout@v2 | |
with: | |
path: kmagick-rs | |
- name: Fetch latest Android shared libs | |
if: matrix.android | |
uses: i3h/download-release-asset@v1 | |
with: | |
tag: latest | |
owner: molotovcherry | |
repo: Android-ImageMagick7 | |
file: imagemagick-7-android-shared.zip | |
path: jniLibs/ | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract archives | |
if: matrix.android | |
run: | | |
Expand-Archive -Path jniLibs/imagemagick-7-android-shared.zip -DestinationPath jniLibs/ | |
- name: Cache ImageMagick Setup | |
if: matrix.windows | |
id: cache-imagemagick | |
uses: actions/cache@v2 | |
with: | |
path: app | |
key: imagemagick-${{ steps.latest_release_im.outputs.tag_name }}-${{ matrix.im_arch }} | |
- name: Download ImageMagick Windows DLL release | |
if: steps.cache-imagemagick.outputs.cache-hit != 'true' && matrix.windows | |
uses: carlosperate/[email protected] | |
with: | |
file-url: 'https://imagemagick.org/archive/binaries/ImageMagick-${{ steps.latest_release_im.outputs.tag_name }}-Q16-HDRI-${{ matrix.im_arch }}-dll.exe' | |
file-name: 'ImageMagick.exe' | |
- name: Fetch latest Innoextract | |
if: steps.cache-imagemagick.outputs.cache-hit != 'true' && matrix.windows | |
uses: i3h/download-release-asset@v1 | |
with: | |
tag: latest | |
owner: dscharrer | |
repo: innoextract | |
file: /innoextract-.*-windows\.zip/ | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# running the installer does not work in the runner | |
- name: Install ImageMagick Windows | |
if: steps.cache-imagemagick.outputs.cache-hit != 'true' && matrix.windows | |
run: | | |
$inno = Resolve-Path -Path innoextract-*-windows.zip | |
Expand-Archive -Path $inno -DestinationPath inno/ | |
inno/innoextract.exe ImageMagick.exe | |
- name: Cache LLVM and Clang | |
id: cache-llvm | |
uses: actions/cache@v2 | |
with: | |
path: | | |
${{ runner.temp }}/llvm | |
key: llvm-12 | |
- name: Install LLVM and Clang # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797 | |
uses: KyleMayes/install-llvm-action@v1 | |
with: | |
version: "12.0" | |
directory: ${{ runner.temp }}/llvm | |
cached: ${{ steps.cache-llvm.outputs.cache-hit }} | |
- name: Set LIBCLANG_PATH | |
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: ${{ matrix.profile }} | |
toolchain: ${{ matrix.toolchain }} | |
target: ${{ matrix.target }} | |
default: true | |
- name: Cache Cargo | |
uses: Swatinem/rust-cache@v1 | |
with: | |
key: ${{ matrix.target }}-release | |
working-directory: kmagick-rs/rust | |
- name: Get NDK | |
if: matrix.android | |
uses: nttld/setup-ndk@v1 | |
with: | |
ndk-version: r22b | |
- name: Fix LLVM NDK Paths | |
if: matrix.android | |
run: | | |
$ndkRoot = Resolve-Path -Path "${{ runner.temp }}/*/android-ndk-r22b" | |
echo "ANDROID_NDK_HOME=$ndkRoot" >> $env:GITHUB_ENV | |
echo "NDK_HOME=$ndkRoot" >> $env:GITHUB_ENV | |
echo "$ndkRoot" >> $env:GITHUB_PATH | |
echo "CLANG_PATH=$ndkRoot\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe" >> $env:GITHUB_ENV | |
echo "$ndkRoot\toolchains\llvm\prebuilt\windows-x86_64\bin\" >> $env:GITHUB_PATH | |
- name: Build | |
working-directory: kmagick-rs/rust | |
run: ./${{ matrix.release.tool }} | |
- name: Rename artifacts | |
working-directory: kmagick-rs/rust | |
run: | | |
Compress-Archive -Path target/${{ matrix.target }}/release/${{ matrix.output }} -DestinationPath kmagick-${{ matrix.target }}.zip | |
- name: Update release artifacts | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: 'kmagick-rs/rust/*.zip' | |
release_id: ${{ steps.latest_release.outputs.id }} | |
overwrite: true | |
draft: false | |
tag_name: ${{ steps.latest_release.outputs.tag_name }} | |
build-kmagick: | |
name: Build KMagick Jar | |
runs-on: windows-latest | |
if: github.event_name != 'repository_dispatch' | |
steps: | |
- name: Get latest release | |
id: latest_release | |
uses: kaliber5/action-get-release@v1 | |
with: | |
token: ${{ github.token }} | |
latest: true | |
- name: Checkout KMagick | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.latest_release.outputs.tag_name }} | |
fetch-depth: '0' | |
- name: Compile Jar | |
run: | | |
./gradlew kmagick:jar | |
./gradlew kmagick:sourcesJar | |
./gradlew kmagick:dokkaHtml | |
- name: Update docs | |
run: | | |
Remove-Item –path docs –recurse | |
mkdir docs | |
Move-Item -Path kmagick/build/dokka/html/* -Destination docs/ | |
# we checked out a tag, we're on a detached branch, so we need to checkout main to commit | |
git checkout main | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
token: ${{ secrets.REPO_SCOPED_TOKEN }} | |
commit-message: Update docs to ${{ steps.latest_release.outputs.tag_name }} | |
committer: GitHub <[email protected]> | |
author: GitHub <[email protected]> | |
signoff: false | |
branch: docsupdate | |
delete-branch: true | |
add-paths: docs | |
title: 'Update docs to ${{ steps.latest_release.outputs.tag_name }}' | |
body: | | |
Hey there! | |
I updated the docs for release ${{ steps.latest_release.outputs.tag_name }} | |
**_[ This was automatically generated by github-actions[bot] ]_** | |
labels: | | |
automated pr | |
draft: false | |
- name: Enable Pull Request Automerge | |
uses: peter-evans/enable-pull-request-automerge@v1 | |
with: | |
token: ${{ secrets.REPO_SCOPED_TOKEN }} | |
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} | |
merge-method: rebase | |
- name: Rename artifacts | |
run: | | |
Move-Item -Path kmagick/build/libs/kmagick-*-sources.jar -Destination ./kmagick-sources.jar | |
Move-Item -Path kmagick/build/libs/kmagick*.jar -Destination ./kmagick.jar | |
- name: Update release artifacts | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
file: '*.jar' | |
release_id: ${{ steps.latest_release.outputs.id }} | |
overwrite: true | |
draft: false | |
tag_name: ${{ steps.latest_release.outputs.tag_name }} |