-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from sifive/automate-release
Create GitHub Actions release automation
- Loading branch information
Showing
4 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
on: | ||
push: | ||
# Require one of the following patterns to match the tag | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+.[0-9]+' # ex. v20.00.00.00 | ||
- 'v[0-9]+.[0-9]+.RC.[0-9]+' # ex. v20.00.RC.00 | ||
|
||
name: Create Release | ||
|
||
env: | ||
PROJECT_NAME: freedom-metal | ||
# Release is a prerelease if the tag contains rc | ||
PRERELEASE: ${{ contains(github.ref, 'RC') }} | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Perform a recursive, PAT-authenticated checkout of all freedom-metal | ||
# submodules. This allows us to update the published docs on github.io. | ||
- name: 'Checkout' | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | ||
|
||
# In order to generate release notes, we need a deep clone of the | ||
# repository so that we can find the most recent tag and generate | ||
# statistics based on it. | ||
- name: 'Fetch History' | ||
run: git fetch --prune --unshallow | ||
|
||
- name: 'Create Release Notes' | ||
id: create-release-notes | ||
run: | | ||
tag=$(echo ${{ github.ref }} | cut -d '/' -f 3) | ||
release_notes=$(./scripts/create-release-notes.sh ${{ env.PROJECT_NAME }} ${tag}) | ||
# The string passed to Actions must urlencode newlines. | ||
release_notes="${release_notes//$'\n'/'%0A'}" | ||
# Use a magic "workflow command" to set the output for the step. | ||
echo "::set-output name=release-notes::${release_notes}" | ||
- name: 'Create Release' | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ env.PROJECT_NAME }} ${{ github.ref }} | ||
body: ${{ steps.create-release-notes.outputs.release-notes }} | ||
draft: false | ||
prerelease: ${{ env.PRERELEASE }} | ||
|
||
- name: 'Build Docker Image for Docs Build' | ||
run: | | ||
docker build -t docs-build -f doc/Dockerfile . | ||
- name: 'Clean Docs Output Folder' | ||
run: | | ||
cd doc/html | ||
git fetch | ||
git checkout master | ||
git reset --hard origin/master | ||
- name: 'Build Sphinx Documentation' | ||
run: | | ||
tag=$(echo ${{ github.ref }} | cut -d '/' -f 3) | ||
docker run \ | ||
--rm \ | ||
-v $(pwd):/freedom-metal \ | ||
-e RELEASE_TAG="${tag}" \ | ||
docs-build \ | ||
make -C /freedom-metal/doc clean html | ||
- name: 'Publish Documentation' | ||
run: | | ||
tag=$(echo ${{ github.ref }} | cut -d '/' -f 3) | ||
cd doc/html | ||
git config user.email "no-reply@sifive.com" | ||
git config user.name "actions-bot" | ||
git add . | ||
git commit -m "Documentation for ${{ env.PROJECT_NAME }} ${tag}" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM sphinxdoc/sphinx | ||
|
||
RUN apt-get update \ | ||
&& apt install -y doxygen graphviz \ | ||
&& apt-get autoremove \ | ||
&& apt-get clean | ||
|
||
RUN python3 -m pip install breathe pydot | ||
|
||
WORKDIR / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2020 SiFive Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euo pipefail | ||
|
||
if [ "$#" -lt 2 ] ; then | ||
>&2 echo "$0: please provide project name and release tag" | ||
exit 1 | ||
fi | ||
|
||
project=$1; shift 1; | ||
current_release=$1; shift 1; | ||
|
||
# Get the most recent previous tag with git-describe. If this is | ||
# the first tag in the repository, then this will return a commit | ||
# hash (because of the --always flag). | ||
last_release=$(git describe --tags --always HEAD~) | ||
|
||
echo "# Release notes for ${project} ${current_release}" | ||
echo "## Statistics since ${last_release}" | ||
echo "- $(git rev-list --count ${last_release}..HEAD) commits" | ||
echo "-$(git diff --shortstat ${last_release} HEAD)" | ||
echo "" | ||
echo "## Authors" | ||
git shortlog -s -n --no-merges ${last_release}..HEAD | cut -f 2 | ||
echo "" | ||
echo "## Merge history" | ||
git log --merges --pretty=format:"%h %b" ${last_release}..HEAD |