name: GitHub Release # Runs when a new tag is created that looks like a version number. # # 1. Creates a draft release on GitHub with the latest release notes # 2. On all combinations of OS, build type, and library type: # a. builds Packager # b. builds the docs # c. runs all tests # d. attaches build artifacts to the release # 3. Fully publishes the release on GitHub # # Publishing the release then triggers additional workflows for NPM, Docker # Hub, and GitHub Pages. # # Can also be run manually for debugging purposes. on: push: tags: - "v*.*" # For manual debugging: workflow_dispatch: inputs: tag: description: "An existing tag to release." required: True jobs: setup: name: Setup runs-on: ubuntu-latest outputs: tag: ${{ steps.compute_tag.outputs.tag }} steps: - name: Compute tag id: compute_tag # We could be building from a workflow dispatch (manual run) # or from a pushed tag. If triggered from a pushed tag, we would like # to strip refs/tags/ off of the incoming ref and just use the tag # name. Subsequent jobs can refer to the "tag" output of this job to # determine the correct tag name in all cases. run: | # Strip refs/tags/ from the input to get the tag name, then store # that in output. echo "::set-output name=tag::${{ github.event.inputs.tag || github.ref }}" \ | sed -e 's@refs/tags/@@' draft_release: name: Create GitHub release needs: setup runs-on: ubuntu-latest outputs: release_id: ${{ steps.draft_release.outputs.id }} steps: - name: Checkout code uses: actions/checkout@v2 with: path: src ref: ${{ needs.setup.outputs.tag }} - name: Check changelog version # This check prevents releases without appropriate changelog updates. run: | cd src VERSION=$(packager/tools/extract_from_changelog.py --version) if [[ "$VERSION" != "${{ needs.setup.outputs.tag }}" ]]; then echo "" echo "" echo "***** ***** *****" echo "" echo "Version mismatch!" echo "Workflow is targetting ${{ needs.setup.outputs.tag }}," echo "but CHANGELOG.md contains $VERSION!" exit 1 fi - name: Extract release notes run: | cd src packager/tools/extract_from_changelog.py --release_notes \ | tee ../RELEASE_NOTES.md - name: Draft release id: draft_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ needs.setup.outputs.tag }} release_name: ${{ needs.setup.outputs.tag }} body_path: RELEASE_NOTES.md draft: true lint: needs: setup name: Lint runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 with: path: src ref: ${{ needs.setup.outputs.tag }} # This makes the merge base available for the C++ linter, so that it # can tell which files have changed. fetch-depth: 2 - name: Lint uses: ./src/.github/workflows/custom-actions/lint-packager build_and_test: needs: [setup, lint, draft_release] strategy: matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest", "self-hosted-linux-arm64"] build_type: ["Debug", "Release"] lib_type: ["static", "shared"] include: - os: ubuntu-latest os_name: linux target_arch: x64 exe_ext: "" build_type_suffix: "" - os: macos-latest os_name: osx target_arch: x64 exe_ext: "" build_type_suffix: "" - os: windows-latest os_name: win target_arch: x64 exe_ext: ".exe" # 64-bit outputs on Windows go to a different folder name. build_type_suffix: "_x64" - os: self-hosted-linux-arm64 os_name: linux target_arch: arm64 exe_ext: "" build_type_suffix: "" name: Build and test ${{ matrix.os_name }} ${{ matrix.target_arch }} ${{ matrix.build_type }} ${{ matrix.lib_type }} runs-on: ${{ matrix.os }} steps: - name: Configure git to preserve line endings # Otherwise, tests fail on Windows because "golden" test outputs will not # have the correct line endings. run: git config --global core.autocrlf false - name: Checkout code uses: actions/checkout@v2 with: path: src ref: ${{ needs.setup.outputs.tag }} - name: Build docs (Linux only) if: runner.os == 'Linux' uses: ./src/.github/workflows/custom-actions/build-docs - name: Build Packager uses: ./src/.github/workflows/custom-actions/build-packager with: os_name: ${{ matrix.os_name }} target_arch: ${{ matrix.target_arch }} lib_type: ${{ matrix.lib_type }} build_type: ${{ matrix.build_type }} build_type_suffix: ${{ matrix.build_type_suffix }} exe_ext: ${{ matrix.exe_ext }} - name: Test Packager uses: ./src/.github/workflows/custom-actions/test-packager with: lib_type: ${{ matrix.lib_type }} build_type: ${{ matrix.build_type }} build_type_suffix: ${{ matrix.build_type_suffix }} exe_ext: ${{ matrix.exe_ext }} - name: Attach artifacts to release if: matrix.build_type == 'Release' && matrix.lib_type == 'static' uses: dwenegar/upload-release-assets@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_id: ${{ needs.draft_release.outputs.release_id }} assets_path: artifacts test_supported_linux_distros: # Doesn't really "need" it, but let's not waste time on a series of docker # builds just to cancel it because of a linter error. needs: lint name: Test builds on all supported Linux distros (using docker) runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 with: path: src ref: ${{ github.event.inputs.ref || github.ref }} - name: Install depot tools shell: bash run: | git clone -b chrome/4147 https://chromium.googlesource.com/chromium/tools/depot_tools.git touch depot_tools/.disable_auto_update echo "${GITHUB_WORKSPACE}/depot_tools" >> $GITHUB_PATH - name: Setup gclient shell: bash run: | gclient config https://github.com/shaka-project/shaka-packager.git --name=src --unmanaged # NOTE: the docker tests will do gclient runhooks, so skip hooks here. gclient sync --nohooks - name: Test all distros shell: bash run: ./src/packager/testing/dockers/test_dockers.sh publish_release: name: Publish GitHub release needs: [draft_release, build_and_test] runs-on: ubuntu-latest steps: - name: Publish release uses: eregon/publish-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: release_id: ${{ needs.draft_release.outputs.release_id }}