jolly 0.2.0

small bookmarking launcher for desktop usage, developed with iced
# Create release builds for Windows, MacOS, Linux
# based on https://jon.sprig.gs/blog/post/2442

name: release
on:
  push:
    # Enable when testing release infrastructure on a branch.
    # branches:
    # - ag/work
    tags:
    - "[0-9]+.[0-9]+.[0-9]+"
jobs:
  create-release:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Create Release
        id: create_release
        uses: softprops/action-gh-release@v1
        with:
          name: ${{ github.ref_name }}
          draft: false
          prerelease: false
          generate_release_notes: false

  build-release:
    name: build-release
    needs: create-release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest, macos-latest]
        
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Build release binary
      run: cargo build --verbose --release

    - name: Strip release binary (linux and macos)
      if: matrix.build == 'linux' || matrix.build == 'macos'
      run: strip "target/release/jolly"

    - name: Build archive
      shell: bash
      run: |
        target=$(rustc -vV | grep host | awk '{ print $2 }')
        staging="jolly-${{  github.ref_name }}-$target"
        mkdir -p "$staging"

        cp {README.md,LICENSE-APACHE,LICENSE-MIT,CHANGELOG.md} "$staging/"
        cp -r docs "$staging"

        if [ "${{ matrix.os }}" = "windows-latest" ]; then
          cp "target/release/jolly.exe" "$staging/"
          7z a "$staging.zip" "$staging"
          echo "ASSET=$staging.zip" >> $GITHUB_ENV
        else
          cp "target/release/jolly" "$staging/"
          tar czf "$staging.tar.gz" "$staging"
          echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
        fi

    - name: Release
      uses: softprops/action-gh-release@v1
      with:
        tag_name: ${{ needs.create_release.outputs.tag-name }}
        files: ${{ env.ASSET }}