python-launcher 0.16.0

The Python launcher for Unix
Documentation
name: Release

on: workflow_dispatch

permissions:
  contents: write

jobs:
  details:
    name: Release details
    runs-on: ubuntu-latest

    outputs:
      version: ${{ steps.version.outputs.release }}
      tag: ${{ steps.version.outputs.tag }}

    steps:
      - uses: actions/checkout@v2

      # OS-specific
      - uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      - name: Install Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.x

      - name: Install dependencies
        run: python -m pip install -r dev-requirements.txt

      - name: Version details
        id: version
        run: |
          echo "::set-output name=release::`python -m release version`"
          echo "::set-output name=tag::`python -m release version --tag`"
        shell: bash

  release:
    name: GitHub release
    needs: details
    runs-on: ubuntu-latest

    steps:
    # Necessary to implicitly specify the repo to create the release for.
      - uses: actions/checkout@v2

      - name: Create release
        # Specify release notes to make creation non-interactive.
        run: gh release create ${{ needs.details.outputs.tag }} --notes "" --draft
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


  build:
    name: Build ${{ matrix.target }}
    needs: [details, release]
    runs-on: ${{ matrix.os }}

    env:
      toolchain: stable

    strategy:
      fail-fast: false
      matrix:
        # https://doc.rust-lang.org/stable/rustc/platform-support.html
        # https://github.com/rust-embedded/cross#supported-targets
        # aarch64-apple-darwin (basically) requires macos-11 to be generally available.
        include:
          - target: x86_64-apple-darwin
            os: macos-latest
            use-cross: false
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            use-cross: false
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            use-cross: true
          - target: riscv64gc-unknown-linux-gnu
            os: ubuntu-latest
            use-cross: true
          - target: x86_64-unknown-netbsd
            os: ubuntu-latest
            use-cross: true

    steps:
      - uses: actions/checkout@v2

      # OS-specific
      - uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      - name: Install Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.x

      - name: Install dependencies
        run: python -m pip install -r dev-requirements.txt

      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ env.toolchain }}
          target: ${{ matrix.target }}
          override: true
          profile: minimal

      - name: Cargo build
        uses: actions-rs/cargo@v1
        with:
          toolchain: ${{ env.toolchain }}
          use-cross: ${{ matrix.use-cross }}
          command: build
          args: --release --target ${{ matrix.target }}

      - name: Strip binary
        if: ${{ !matrix.use-cross }}
        run: |
          du -h target/${{ matrix.target }}/release/py
          strip target/${{ matrix.target }}/release/py
          du -h target/${{ matrix.target }}/release/py

      - name: Create tarball
        run: |
          TARBALL_PATH=`python -m release tarball --target ${{ matrix.target }}`
          du -h $TARBALL_PATH
          tar -tvf $TARBALL_PATH
          echo "tarball_path=$TARBALL_PATH" >> $GITHUB_ENV

      - name: Upload tarball
        run: gh release upload ${{ needs.details.outputs.tag }} ${{ env.tarball_path }} --clobber
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}