mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-18 16:36:56 +03:00
a4ddab37d5
A couple of steps were in the wrong order. We must compute tags and subdomains before the "prep" step, which wipes out .git.
167 lines
5.8 KiB
YAML
167 lines
5.8 KiB
YAML
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:
|
|
# Without this command, the manifest file will be ignored. At least
|
|
# for our initial main-branch releases using this workflow, we must
|
|
# use the manifest and config file.
|
|
command: manifest
|
|
config-file: .release-please-config.json
|
|
manifest-file: .release-please-manifest.json
|
|
# Make sure the player version gets updated.
|
|
extra-files: lib/player.js
|
|
# Make sure we create the PR against the correct branch.
|
|
default-branch: ${{ github.ref_name }}
|
|
|
|
# If we didn't create a release, we may have created or updated a PR.
|
|
- uses: actions/checkout@v2
|
|
if: steps.release.outputs.release_created == false
|
|
- name: Custom update Player version
|
|
if: steps.release.outputs.release_created == false
|
|
run: |
|
|
# Check out the branch that release-please created, if it exists.
|
|
git fetch
|
|
git checkout release-please--branches--${{ github.ref_name }} || exit 0
|
|
# If it does exist, update lib/player.js in the PR branch, so that the
|
|
# -uncompiled tag remains in the player version in that context.
|
|
VERSION="v$(jq -r .version package.json)-uncompiled"
|
|
sed -e "s/^\\(shaka.Player.version =\\).*/\\1 '$VERSION';/" \
|
|
-i lib/player.js
|
|
git add lib/player.js
|
|
# Emulate the actions bot.
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
# Update the PR.
|
|
git commit --amend --no-edit
|
|
git push -f
|
|
|
|
# The jobs below are all conditional on a release having been created by
|
|
# someone merging the release PR. They all run in parallel.
|
|
|
|
tag-main:
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: needs.release.outputs.release_created
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Tag the main branch
|
|
run: |
|
|
# Emulate the actions bot.
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
VERSION=${{ needs.release.outputs.tag_name }}
|
|
git tag -m "$VERSION-main" "$VERSION-main"
|
|
git push origin "$VERSION-main"
|
|
|
|
npm:
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: needs.release.outputs.release_created
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 16
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- run: npm ci
|
|
- run: npm publish
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
|
|
- run: npm pack
|
|
- uses: svenstaro/upload-release-action@483c1e56f95e88835747b1c7c60581215016cbf2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
tag: ${{ needs.release.outputs.tag_name }}
|
|
file: shaka-player-*.tgz
|
|
file_glob: true
|
|
overwrite: true
|
|
|
|
appspot:
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: needs.release.outputs.release_created
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 16
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Compute appspot subdomain and promotion
|
|
run: |
|
|
# This is the same as the version tag, but with dots replaced by
|
|
# dashes. For example, v3.2.2 would have the subdomain v3-2-2.
|
|
APPSPOT_SUBDOMAIN=$( echo ${{ needs.release.outputs.tag_name }} | sed -e 's/\./-/' )
|
|
echo APPSPOT_SUBDOMAIN=$APPSPOT_SUBDOMAIN >> $GITHUB_ENV
|
|
|
|
# "Promoting" an appspot deployment makes it the default which shows
|
|
# up on shaka-player-demo.appspot.com (no subdomain). This should be
|
|
# done for the latest release version from the latest release branch.
|
|
RELEASE_TAGS=$(git tag | grep ^v[0-9] | grep -Ev -- '-(master|main)')
|
|
LATEST_RELEASE=$(echo "$RELEASE_TAGS" | sort --version-sort | tail -1)
|
|
TAG_NAME=${{ needs.release.outputs.tag_name }}
|
|
|
|
if [[ "$TAG_NAME" == "$LATEST_RELEASE" ]]; then
|
|
echo APPSPOT_PROMOTE=true >> $GITHUB_ENV
|
|
else
|
|
echo APPSPOT_PROMOTE=false >> $GITHUB_ENV
|
|
fi
|
|
|
|
# Debug the decisions made here.
|
|
echo "Subdomain: $APPSPOT_SUBDOMAIN"
|
|
echo "Latest release: $LATEST_RELEASE"
|
|
echo "This release: $TAG_NAME"
|
|
echo "Promote: $APPSPOT_PROMOTE"
|
|
|
|
- uses: ./.github/workflows/custom-actions/prep-for-appspot
|
|
|
|
- uses: google-github-actions/auth@v0
|
|
with:
|
|
credentials_json: '${{ secrets.APPENGINE_DEPLOY_KEY }}'
|
|
|
|
- uses: google-github-actions/deploy-appengine@v0
|
|
with:
|
|
project_id: shaka-player-demo
|
|
version: ${{ env.APPSPOT_SUBDOMAIN }}
|
|
promote: ${{ env.APPSPOT_PROMOTE }}
|
|
|
|
auto-branch:
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: needs.release.outputs.release_created && endsWith(needs.release.outputs.tag_name, '.0')
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Create release branch
|
|
run: |
|
|
TAG=${{ needs.release.outputs.tag_name }}
|
|
BRANCH=$(echo "$TAG" | sed -e 's/\.0$/.x/')
|
|
git push origin HEAD:"$BRANCH"
|