Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #478 from sifive/automate-release
Browse files Browse the repository at this point in the history
Create GitHub Actions release automation
  • Loading branch information
nategraff-sifive authored May 1, 2020
2 parents 950dd49 + c817c70 commit 81dfe84
Show file tree
Hide file tree
Showing 16 changed files with 172 additions and 23 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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-e-sdk
# 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-e-sdk
# submodules. This allows us to create and push tags to each submodule,
# triggering their own release workflow.
- 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

# We tag submodules before creating the release notes or the release
# to make sure that they get tagged.
- name: 'Tag Submodules for Release'
run: |
tag=$(echo ${{ github.ref }} | cut -d '/' -f 3)
./scripts/tag-submodules.sh ${tag}
- 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: 'Clean Documentation Output Folder'
run: |
cd doc/html
git fetch
git checkout master
git reset --hard origin/master
rm -rf * .buildinfo .doctrees
- name: 'Build Sphinx Documenattion'
run: |
tag=$(echo ${{ github.ref }} | cut -d '/' -f 3)
docker run \
--rm \
-v $(pwd)/doc:/docs \
-e RELEASE_TAG="${tag}" \
sphinxdoc/sphinx \
make 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
2 changes: 1 addition & 1 deletion FreeRTOS-metal
2 changes: 1 addition & 1 deletion Segger_SystemView-metal
2 changes: 1 addition & 1 deletion doc/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author = 'SiFive Inc.'

# The short X.Y version
version = "master"
version = os.environ['RELEASE_TAG']
# The full version, including alpha/beta/rc tags
release = version

Expand Down
2 changes: 1 addition & 1 deletion freedom-devicetree-tools
2 changes: 1 addition & 1 deletion freedom-metal
2 changes: 1 addition & 1 deletion scl-metal
2 changes: 1 addition & 1 deletion scripts/cmsis-svd-generator
29 changes: 29 additions & 0 deletions scripts/create-release-notes.sh
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
2 changes: 1 addition & 1 deletion scripts/elf2hex
2 changes: 1 addition & 1 deletion scripts/esdk-settings-generator
2 changes: 1 addition & 1 deletion scripts/ldscript-generator
2 changes: 1 addition & 1 deletion scripts/openocdcfg-generator
31 changes: 31 additions & 0 deletions scripts/tag-submodules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -euo pipefail

if [ "$#" -lt 1 ] ; then
>&2 echo "Please provide a tag"
exit 1
fi

tag=$1; shift 1;

submodules=(\
freedom-metal \
freedom-devicetree-tools \
FreeRTOS-metal \
Segger_SystemView-metal \
scl-metal \
scripts/cmsis-svd-generator \
scripts/devicetree-overlay-generator \
scripts/elf2hex \
scripts/esdk-settings-generator \
scripts/ldscript-generator \
scripts/openocdcfg-generator \
)

set -x

for submodule in ${submodules[@]} ; do
git -C ${submodule} tag ${tag}
git -C ${submodule} push -f origin ${tag}
done
22 changes: 11 additions & 11 deletions wit-manifest.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
[
{
"commit": "becd685e7fbbe99f97b3c8379625b7d8b69b97c8",
"commit": "1688a3628f59d313ee09ae18a2a21b22617147f5",
"name": "freedom-devicetree-tools",
"source": "git@github.com:sifive/freedom-devicetree-tools.git"
},
{
"commit": "65169b74dbd71a036ade7d76f982bb750ab718c5",
"commit": "2d7509dd4c2cabcdc8283cfac1aba1f049d7128c",
"name": "freedom-metal",
"source": "git@github.com:sifive/freedom-metal.git"
},
{
"commit": "980f9b9929701ec526d73c59cf39923ef570d599",
"commit": "86a9a524b436774a00ad3d7491ec5e1755c7d0a3",
"name": "elf2hex",
"source": "git@github.com:sifive/elf2hex.git"
},
{
"commit": "fd780fe5b94ae13e8606cdcd5bea417ba5232ce8",
"commit": "f10cf34fa3ae59b0e21b05e0169ec110c7e932a0",
"name": "devicetree-overlay-generator",
"source": "git@github.com:sifive/devicetree-overlay-generator.git"
},
{
"commit": "c13f43e3756d81f7c5e3103ebefd968a9af2117d",
"commit": "606c28cc8de9883970aeea88fcd302c0651023d6",
"name": "ldscript-generator",
"source": "git@github.com:sifive/ldscript-generator.git"
},
{
"commit": "3d667f2c0ecd1ce54d5364fd49f7b302f589a21c",
"commit": "96d383388db020664dd3eb24072945fcc8984a64",
"name": "cmsis-svd-generator",
"source": "git@github.com:sifive/cmsis-svd-generator.git"
},
{
"commit": "573c181ef7c5317585114b1558e2049dd264aa80",
"commit": "33e3954ed786d8ad792bf43e1785b352841b5ed6",
"name": "openocdcfg-generator",
"source": "git@github.com:sifive/openocdcfg-generator.git"
},
{
"commit": "e2115a8ba271d42740b1395531ca9bdeb0f19016",
"commit": "29049568fa975b9afd8282299e5550929902a67f",
"name": "esdk-settings-generator",
"source": "git@github.com:sifive/esdk-settings-generator.git"
},
Expand Down Expand Up @@ -200,12 +200,12 @@
"source": "git@github.com:sifive/benchmark-mem-latency.git"
},
{
"commit": "6e2f8115fcd7ba60e141b5e2d84bf2209df26adb",
"commit": "d9be8c5925ccbe3f205c6d8d0630fb58bc13e3f0",
"name": "FreeRTOS-metal",
"source": "git@github.com:sifive/FreeRTOS-metal.git"
},
{
"commit": "f459c36cfd42e7a67843618117221f79980a9ffc",
"commit": "c506533822fb6b542d13f015c02985664cfeeb67",
"name": "Segger_SystemView-metal",
"source": "git@github.com:sifive/Segger_SystemView-metal.git"
},
Expand Down Expand Up @@ -250,7 +250,7 @@
"source": "git@github.com:sifive/example-hpm.git"
},
{
"commit": "12e6ebb520e253751b1f9923339f26abcde27e30",
"commit": "66dbef1d0f4bcf1fd779f0835946842de706b973",
"name": "scl-metal",
"source": "git@github.com:sifive/scl-metal.git"
},
Expand Down

0 comments on commit 81dfe84

Please sign in to comment.