147 lines
4.8 KiB
YAML
147 lines
4.8 KiB
YAML
|
# Copyright 2023 Google LLC
|
||
|
#
|
||
|
# Use of this source code is governed by a BSD-style
|
||
|
# license that can be found in the LICENSE file or at
|
||
|
# https://developers.google.com/open-source/licenses/bsd
|
||
|
|
||
|
name: Release
|
||
|
|
||
|
on:
|
||
|
push:
|
||
|
branches:
|
||
|
- main
|
||
|
- v[0-9]*
|
||
|
|
||
|
jobs:
|
||
|
release:
|
||
|
runs-on: ubuntu-latest
|
||
|
outputs:
|
||
|
release_created: ${{ steps.release.outputs.release_created }}
|
||
|
tag_name: ${{ steps.release.outputs.tag_name }}
|
||
|
steps:
|
||
|
# Create/update release PR
|
||
|
- uses: google-github-actions/release-please-action@v3
|
||
|
id: release
|
||
|
with:
|
||
|
# Required input to specify the release type. This is not really a
|
||
|
# go project, but go projects in release-please only update
|
||
|
# CHANGELOG.md and nothing else. This is what we want.
|
||
|
release-type: go
|
||
|
# Make sure we create the PR against the correct branch.
|
||
|
default-branch: ${{ github.ref_name }}
|
||
|
# Use a special shaka-bot access token for releases.
|
||
|
token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
|
||
|
# Temporary settings to bootstrap v3.0.0.
|
||
|
last-release-sha: 634af6591ce8c701587a78042ae7f81761725710
|
||
|
bootstrap-sha: 634af6591ce8c701587a78042ae7f81761725710
|
||
|
|
||
|
# The jobs below are all conditional on a release having been created by
|
||
|
# someone merging the release PR.
|
||
|
|
||
|
# Several actions either only run on the latest release or run with different
|
||
|
# options on the latest release. Here we compute if this is the highest
|
||
|
# version number (what we are calling "latest" for NPM, Docker, and the
|
||
|
# docs). You can have a more recent release from an older branch, but this
|
||
|
# would not qualify as "latest" here.
|
||
|
compute:
|
||
|
name: Compute latest release flag
|
||
|
runs-on: ubuntu-latest
|
||
|
needs: release
|
||
|
if: needs.release.outputs.release_created
|
||
|
outputs:
|
||
|
latest: ${{ steps.compute.outputs.latest }}
|
||
|
steps:
|
||
|
- uses: actions/checkout@v3
|
||
|
with:
|
||
|
fetch-tags: true
|
||
|
persist-credentials: false
|
||
|
|
||
|
- name: Compute latest
|
||
|
id: compute
|
||
|
run: |
|
||
|
GIT_TAG_NAME=${{ needs.release.outputs.tag_name }}
|
||
|
RELEASE_TAGS=$(git tag | grep ^v[0-9])
|
||
|
LATEST_RELEASE=$(echo "$RELEASE_TAGS" | sort --version-sort | tail -1)
|
||
|
if [[ "$GIT_TAG_NAME" == "$LATEST_RELEASE" ]]; then
|
||
|
LATEST=true
|
||
|
else
|
||
|
LATEST=false
|
||
|
fi
|
||
|
echo latest=$LATEST >> $GITHUB_OUTPUT
|
||
|
|
||
|
# Debug the decisions made here.
|
||
|
echo "This release: $GIT_TAG_NAME"
|
||
|
echo "Latest release: $LATEST_RELEASE"
|
||
|
echo "This release is latest: $LATEST"
|
||
|
|
||
|
# Publish docs to GitHub Pages
|
||
|
docs:
|
||
|
name: Update docs
|
||
|
needs: [release, compute]
|
||
|
# Only if this is the latest release
|
||
|
if: needs.release.outputs.release_created && needs.compute.outputs.latest
|
||
|
uses: ./.github/workflows/publish-docs.yaml
|
||
|
with:
|
||
|
ref: ${{ github.ref }}
|
||
|
|
||
|
# Publish official docker image
|
||
|
docker:
|
||
|
name: Update docker image
|
||
|
needs: [release, compute]
|
||
|
if: needs.release.outputs.release_created
|
||
|
uses: ./.github/workflows/publish-docker.yaml
|
||
|
with:
|
||
|
tag: ${{ needs.release.outputs.tag_name }}
|
||
|
latest: ${{ needs.compute.outputs.latest == 'true' }}
|
||
|
secrets:
|
||
|
DOCKERHUB_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }}
|
||
|
DOCKERHUB_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }}
|
||
|
DOCKERHUB_PACKAGE_NAME: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}
|
||
|
|
||
|
# Do a complete build
|
||
|
build:
|
||
|
name: Build
|
||
|
needs: release
|
||
|
if: needs.release.outputs.release_created
|
||
|
uses: ./.github/workflows/build.yaml
|
||
|
with:
|
||
|
ref: ${{ github.ref }}
|
||
|
|
||
|
# Attach build artifacts to the release
|
||
|
artifacts:
|
||
|
name: Artifacts
|
||
|
runs-on: ubuntu-latest
|
||
|
needs: [release, build]
|
||
|
if: needs.release.outputs.release_created
|
||
|
steps:
|
||
|
- uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
path: artifacts
|
||
|
|
||
|
- name: Debug
|
||
|
run: find -ls
|
||
|
|
||
|
- name: Attach packager to release
|
||
|
uses: svenstaro/upload-release-action@v2
|
||
|
with:
|
||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||
|
tag: ${{ needs.release.outputs.tag_name }}
|
||
|
make_latest: false # Already set for the release
|
||
|
file_glob: true
|
||
|
file: artifacts/artifacts*/*
|
||
|
overwrite: true
|
||
|
|
||
|
# Surprisingly, Shaka Packager binaries can be installed via npm.
|
||
|
# Publish NPM package updates.
|
||
|
npm:
|
||
|
name: Update NPM
|
||
|
needs: [release, compute, artifacts]
|
||
|
if: needs.release.outputs.release_created
|
||
|
uses: ./.github/workflows/publish-npm.yaml
|
||
|
with:
|
||
|
tag: ${{ needs.release.outputs.tag_name }}
|
||
|
latest: ${{ needs.compute.outputs.latest == 'true' }}
|
||
|
secrets:
|
||
|
NPM_CI_TOKEN: ${{ secrets.NPM_CI_TOKEN }}
|
||
|
NPM_PACKAGE_NAME: ${{ secrets.NPM_PACKAGE_NAME }}
|