Skip to content

Commit

Permalink
ci: Rewrite release workflows
Browse files Browse the repository at this point in the history
This adopts release-please to manage releases and changelogs, similar
to other shaka-project repos.
  • Loading branch information
joeyparrish committed Oct 20, 2023
1 parent f548107 commit 63b8302
Show file tree
Hide file tree
Showing 15 changed files with 335 additions and 338 deletions.
43 changes: 27 additions & 16 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
- `build-docs.yaml`:
Build Packager docs. Runs only on Linux.

- `docker-image.yaml`:
- `build-docker.yaml`:
Build the official Docker image.

- `lint.yaml`:
Lint Shaka Packager.

- `publish-docs.yaml`:
Publish Packager docs. Runs on the latest release.

- `publish-docker.yaml`:
Publish the official docker image. Runs on all releases.

- `publish-npm.yaml`:
Publish binaries to NPM. Runs on all releases.

- `test-linux-distros.yaml`:
Test the build on all Linux distros via docker.

Expand All @@ -22,30 +31,32 @@
- `lint.yaml`
- `build.yaml`
- `build-docs.yaml`
- `docker-image.yaml`
- `build-docker.yaml`
- `test-linux-distros.yaml`

- On release tag (`github-release.yaml`):
- Create a draft release
- Invoke:
- `lint.yaml`
- `build.yaml`
- `test-linux-distros.yaml`
- Publish the release with binaries from `build.yaml` attached

- On release published:
- `docker-hub-release.yaml`, publishes the official Docker image
- `npm-release.yaml`, publishes the official NPM package
- `update-docs.yaml`:
- Invoke `build-docs.yaml`
- Push the output to the `gh-pages` branch
## Release workflow
- `release-please.yaml`
- Updates changelogs, version numbers based on conventional commits syntax
and semantic versioning
- https://conventionalcommits.org/
- https://semver.org/
- Generates/updates a PR on each push
- When the PR is merged, runs additional steps:
- Creates a GitHub release
- Invokes `publish-docs.yaml` to publish the docs
- Invokes `publish-docker.yaml` to publish the docker image
- Invokes `build.yaml`
- Attaches the binaries from `build.yaml` to the GitHub release
- Invokes `publish-npm.yaml` to publish the binaries to NPM

## Common workflows from shaka-project
- `sync-labels.yaml`
- `update-issues.yaml`
- `validate-pr-title.yaml`

## Required Repo Secrets
- `RELEASE_PLEASE_TOKEN`: A PAT for `shaka-bot` to run the `release-please`
action
- `DOCKERHUB_CI_USERNAME`: The username of the Docker Hub CI account
- `DOCKERHUB_CI_TOKEN`: An access token for Docker Hub
- To generate, visit https://hub.docker.com/settings/security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref || github.ref }}
ref: ${{ github.event.inputs.ref }}
submodules: recursive

- name: Build
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ jobs:
cp -a build/doxygen/html gh-pages/docs
cp docs/index.html gh-pages/index.html
- name: Upload docs artifacts
uses: actions/upload-pages-artifact@v2
with:
path: gh-pages

- name: Debug
uses: mxschmitt/[email protected]
with:
Expand Down
133 changes: 0 additions & 133 deletions .github/workflows/github-release.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
# NOTE: Must use base.sha instead of base.ref, since we don't have
# access to the branch name that base.ref would give us.
# NOTE: Must also use fetch-depth: 2 in actions/checkout to have access
# to the base ref for comparison.
# NOTE: Must also use fetch-depth: 2 in actions/checkout to have
# access to the base ref for comparison.
packager/tools/git/check_formatting.py \
--binary /usr/bin/clang-format \
${{ github.event.pull_request.base.sha || 'HEAD^' }}
Expand Down
60 changes: 0 additions & 60 deletions .github/workflows/npm-release.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
official_docker_image:
needs: lint
name: Official Docker image
uses: ./.github/workflows/docker-image.yaml
uses: ./.github/workflows/build-docker.yaml
with:
ref: ${{ github.event.inputs.ref || github.ref }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd

name: Docker Hub Release
# A workflow to publish the official docker image.
name: Publish to Docker Hub

# Runs when a new release is published on GitHub.
# Creates a corresponding Docker Hub release and publishes it.
#
# Runs when called from another workflow.
# Can also be run manually for debugging purposes.
on:
release:
types: [published]
workflow_call:
inputs:
tag:
required: true
type: string
latest:
required: true
type: boolean
# For manual debugging:
workflow_dispatch:
inputs:
ref:
description: "The tag to release to Docker Hub."
tag:
description: The tag to build from and to push to.
required: True
latest:
description: If true, push to the "latest" tag.
required: True

jobs:
publish_docker_hub:
name: Publish to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Compute ref
id: ref
# We could be building from a workflow dispatch (manual run), or a
# release event. Subsequent steps can refer to $TARGET_REF to
# determine the correct ref in all cases.
run: |
echo "TARGET_REF=${{ github.event.inputs.ref || github.event.release.tag_name }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ env.TARGET_REF }}
ref: ${{ github.event.inputs.tag }}
submodules: recursive

- name: Log in to Docker Hub
Expand All @@ -49,4 +49,11 @@ jobs:
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest,${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ env.TARGET_REF }}
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:${{ github.event.inputs.tag }}

- name: Push to Docker Hub as "latest"
if: ${{ github.event.inputs.latest }}
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_PACKAGE_NAME }}:latest
Loading

0 comments on commit 63b8302

Please sign in to comment.