Skip to content

Commit

Permalink
Refactor CICD: change trigger by tag and add release note template
Browse files Browse the repository at this point in the history
  • Loading branch information
Hien To committed Oct 12, 2023
1 parent ac5c5be commit 0303a50
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 35 deletions.
28 changes: 28 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name-template: '$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'type: enhancement'
- 'type: epic'
- 'type: feature request'
- title: '🐛 Bug Fixes'
labels:
- 'type: bug'
- title: '🧰 Maintenance'
labels:
- 'type: chore'
- 'type: ci'
- title: '📖 Documentaion'
labels:
- 'type: documentation'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
template: |
## Changes
$CHANGES
## Contributor
$CONTRIBUTORS
109 changes: 74 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: CI

on:
workflow_dispatch: # allows manual triggering
inputs:
create_release:
description: 'Create new release'
required: true
type: boolean
push:
branches:
- master
- main
tags: ['v*.*.*']
paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu']
pull_request:
types: [opened, synchronize, reopened]
Expand Down Expand Up @@ -62,13 +57,18 @@ jobs:
zip -r nitro.zip nitro
- name: Upload binaries to release
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: nitro.zip
asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64.zip
tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
RELEASE_ID=$(gh release view "${GITHUB_REF#refs/tags/v}" --repo ${{ github.repository }} -q ".id" || echo "")
if [[ -z "$RELEASE_ID" ]]; then
gh release create \
"${GITHUB_REF#refs/tags/v}" \
--repo ${{ github.repository }} \
--title "${GITHUB_REF#refs/tags/v}" \
--notes "Release notes for ${GITHUB_REF#refs/tags/v}" \
--draft || true
fi
gh release upload "${GITHUB_REF#refs/tags/v}" nitro.zip --name "nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64.zip" --repo ${{ github.repository }} --clobber
ubuntu-amd64-cuda-build:
runs-on: linux-gpu
Expand Down Expand Up @@ -114,13 +114,18 @@ jobs:
zip -r nitro.zip nitro
- name: Upload binaries to release
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: nitro.zip
asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64-cuda.zip
tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
RELEASE_ID=$(gh release view "${GITHUB_REF#refs/tags/v}" --repo ${{ github.repository }} -q ".id" || echo "")
if [[ -z "$RELEASE_ID" ]]; then
gh release create \
"${GITHUB_REF#refs/tags/v}" \
--repo ${{ github.repository }} \
--title "${GITHUB_REF#refs/tags/v}" \
--notes "Release notes for ${GITHUB_REF#refs/tags/v}" \
--draft || true
fi
gh release upload "${GITHUB_REF#refs/tags/v}" nitro.zip --name "nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64-cuda.zip" --repo ${{ github.repository }} --clobber
macOS-M-build:
runs-on: mac-silicon
Expand Down Expand Up @@ -168,13 +173,18 @@ jobs:
zip -r nitro.zip nitro
- name: Upload binaries to release
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: nitro.zip
asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-arm64.zip
tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
RELEASE_ID=$(gh release view "${GITHUB_REF#refs/tags/v}" --repo ${{ github.repository }} -q ".id" || echo "")
if [[ -z "$RELEASE_ID" ]]; then
gh release create \
"${GITHUB_REF#refs/tags/v}" \
--repo ${{ github.repository }} \
--title "${GITHUB_REF#refs/tags/v}" \
--notes "Release notes for ${GITHUB_REF#refs/tags/v}" \
--draft || true
fi
gh release upload "${GITHUB_REF#refs/tags/v}" nitro.zip --name "nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-arm64.zip" --repo ${{ github.repository }} --clobber
macOS-Intel-build:
runs-on: macos-latest
Expand Down Expand Up @@ -220,10 +230,39 @@ jobs:
zip -r nitro.zip nitro
- name: Upload binaries to release
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: nitro.zip
asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip
tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
RELEASE_ID=$(gh release view "${GITHUB_REF#refs/tags/v}" --repo ${{ github.repository }} -q ".id" || echo "")
if [[ -z "$RELEASE_ID" ]]; then
gh release create \
"${GITHUB_REF#refs/tags/v}" \
--repo ${{ github.repository }} \
--title "${GITHUB_REF#refs/tags/v}" \
--notes "Release notes for ${GITHUB_REF#refs/tags/v}" \
--draft || true
fi
gh release upload "${GITHUB_REF#refs/tags/v}" nitro.zip --name "nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip" --repo ${{ github.repository }} --clobber
update_release_draft:
needs: [ubuntu-amd64-build, ubuntu-amd64-cuda-build, macOS-M-build, macOS-Intel-build]
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 0303a50

Please sign in to comment.