name: Manual

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - nickname: win
            os: windows-latest
            graal: 22.3.0
            musl: false
          - nickname: macos
            os: macos-latest
            graal: 22.3.0
            musl: false
          - nickname: linux
            os: ubuntu-latest
            graal: 22.3.0
            musl: true
    name: Build ${{ matrix.nickname }}
    steps:
      - uses: actions/checkout@v3
      - uses: graalvm/setup-graalvm@v1
        with:
          version: ${{ matrix.graal }}
          java-version: 17
          components: native-image
          native-image-musl: ${{ matrix.musl }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
      - run: |
          ./gradlew build nativeCompile -PspringShellSampleMusl=${{ matrix.musl }} -x test
      - uses: actions/upload-artifact@v3
        with:
          name: spring-shell-samples-${{ matrix.nickname }}
          retention-days: 1
          path: |
            spring-shell-samples/build/libs/*.jar
            spring-shell-samples/build/native/nativeCompile/spring-shell-samples
            spring-shell-samples/build/native/nativeCompile/spring-shell-samples.exe
