Skip to content

Commit

Permalink
action: use release drafter for the release generation when a git tag…
Browse files Browse the repository at this point in the history
… release is created (#240)
  • Loading branch information
v1v authored Oct 18, 2022
1 parent ca5ef63 commit 8611dec
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 60 deletions.
5 changes: 0 additions & 5 deletions .ci/scripts/gren

This file was deleted.

7 changes: 0 additions & 7 deletions .ci/scripts/release-notes.sh

This file was deleted.

56 changes: 56 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bug'
- title: '📚 Documentation'
labels:
- 'docs'
- 'question'
- title: '🧰 Maintenance'
label:
- 'chore'
- 'ci'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Go $RESOLVED_VERSION
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-arm` - linux/arm64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armel` - linux/armv5, linux/armv6
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main` - linux/i386, linux/amd64, windows/386, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian7` - linux/i386, linux/amd64, windows/386, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian8` - linux/i386, linux/amd64, windows/386, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian9` - linux/i386, linux/amd64, windows/386, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian10` - linux/i386, linux/amd64, windows/386, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian11` - linux/i386, linux/amd64, windows/386, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-mips` - linux/mips64, linux/mips64el
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-mips32` - linux/mips, linux/mipsle
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-ppc` - linux/ppc64, linux/ppc64le
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-s390x` - linux/s390x
### Changes
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
32 changes: 32 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Release Drafter

on:
push:
tags:
- v*.*

permissions:
contents: read

jobs:
update_release_draft:
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:
- name: version
id: version
run: |
tag=${GITHUB_REF/refs\/tags\//}
version=${tag#v}
echo "::set-output name=version::${version}"
- uses: release-drafter/release-drafter@v5
with:
version: ${{ steps.version.outputs.version }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ _obj
Dockerfile
.status.*
*.bck
CHANGELOG.md
npcap/lib/*.exe

38 changes: 0 additions & 38 deletions .grenrc.js

This file was deleted.

14 changes: 5 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,13 @@ def isNewRelease() {
def postRelease(){
deleteDir()
unstash 'source'
dockerLogin(secret: "${env.DOCKER_REGISTRY_SECRET}", registry: "${env.DOCKER_REGISTRY}")
dir("${env.BASE_DIR}"){
sh(label: 'Set branch', script: """#!/bin/bash
git checkout -b ${BRANCH_NAME}
""")
sh(label: 'Set branch', script: "git checkout -b ${BRANCH_NAME}")
try {
gitCreateTag(tag: "${env.GO_VERSION}", pushArgs: '--force')
withCredentials([string(credentialsId: '2a9602aa-ab9f-4e52-baf3-b71ca88469c7', variable: 'GREN_GITHUB_TOKEN')]) {
sh(label: 'Creating Release Notes', script: '.ci/scripts/release-notes.sh')
}
gh(command: "release create ${env.GO_VERSION}", flags: [ "notes-file": ['CHANGELOG.md'], title: "${env.GO_VERSION}" ])
// Tag with v<GO_VERSION>
// This will help issues with major.minor branches for the very first
// golang release, since patch verison doesn't exist.
gitCreateTag(tag: "v${env.GO_VERSION}", pushArgs: '--force')
} catch (e) {
// Probably the tag already exists
log(level: 'WARN', text: "postRelease failed with message : ${e?.message}")
Expand Down

0 comments on commit 8611dec

Please sign in to comment.