Skip to content

Commit

Permalink
Merge pull request #690 from andreasfertig/ghReleaseWorkflow
Browse files Browse the repository at this point in the history
Support for automatically building a GitHub release.
  • Loading branch information
andreasfertig authored Jan 11, 2025
2 parents a2a5015 + 46b1f35 commit 66cf8b2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches-ignore:
- 'continuous'
tags:
- 'v_*'

pull_request:
branches-ignore:
Expand Down Expand Up @@ -689,12 +691,27 @@ jobs:
#------------------------------------------------------------------------------
deploy:
needs: [build, docker, in-source-tree]
if: github.ref == 'refs/heads/main'
if: ${{ (github.ref == 'refs/heads/main') || contains(github.ref, 'refs/tags/v_') }}
name: Final Deploy
continue-on-error: false
runs-on: ubuntu-22.04

steps:
- name: Get release info
id: release_info
shell: bash
run: |
tag_name=""
if [[ "${{ github.ref }}" == *"refs/tags/v_"* ]]; then
tag_name="${{ github.ref_name }}"
else
tag_name="continuous"
fi
echo "Tag: ${tag_name}"
echo "tag_name=${tag_name}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
path: cppinsights
Expand All @@ -720,21 +737,21 @@ jobs:
shell: bash
run: |
cd ${GITHUB_WORKSPACE}/cppinsights
gren changelog --generate --override --username=andreasfertig --repo=cppinsights -t continuous..`git tag --sort=-creatordate | grep -v continuous | head -n 1 ` -c .github/grenrc.json
gren changelog --generate --override --username=andreasfertig --repo=cppinsights -t ${{ steps.release_info.outputs.tag_name }} --limit 1 -c .github/grenrc.json
sed -in '1,4d' CHANGELOG.md
- name: Create Release
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "/home/runner/binaries/insights-artifact-*/insights-*"
token: ${{ secrets.GITHUB_TOKEN }}
bodyFile: "${{ github.workspace }}/cppinsights/CHANGELOG.md"
allowUpdates: true
artifactErrorsFailBuild: true
name: continuous
prerelease: true
name: ${{ steps.release_info.outputs.tag_name }}
prerelease: ${{ steps.release_info.outputs.tag_name }} == 'continuous'
removeArtifacts: true
tag: continuous
tag: ${{ steps.release_info.outputs.tag_name }}
generateReleaseNotes: false

- name: Upload docs to gh-pages
Expand Down
5 changes: 5 additions & 0 deletions scripts/llvm-coverage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#! /usr/bin/env python3
#
#
# C++ Insights, copyright (C) by Andreas Fertig
# Distributed under an MIT license. See LICENSE for details
#
#------------------------------------------------------------------------------

import os
Expand Down
41 changes: 13 additions & 28 deletions scripts/prepare-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
def main():
versionH = open('version.h.in', 'r').read()

oldClangStable = '17'
newClangStable = '18'
newInsightsVersion = '18.0'
oldClangStable = '18'
newClangStable = '19'
newInsightsVersion = f'{newClangStable}.0'
oldInsightsVersion = re.search(r'INSIGHTS_VERSION\s+"(.*?)"', versionH, re.DOTALL | re.MULTILINE).group(1)


Expand All @@ -40,7 +40,6 @@ def main():
travis = re.sub(r"(llvm-toolchain-xenial)-(%s)" %(oldClangStable), r"\1-%s" %(newClangStable) , travis)
travis = re.sub(r"(./llvm.sh) (%s)" %(oldClangStable), r"\1 %s" %(newClangStable) , travis)

# print(travis)
open('.github/workflows/ci.yml', 'w').write(travis)


Expand All @@ -50,32 +49,23 @@ def main():
open('CMakeLists.txt', 'w').write(cmake)


print(' - Updating version.h %s -> %s' %(oldInsightsVersion, newInsightsVersion))
print(f' - Updating version.h {oldInsightsVersion} -> {newInsightsVersion}')
version = open('version.h.in', 'r').read()
version = re.sub('(INSIGHTS_VERSION )"(.*)"', '\\1"%s"' %(newInsightsVersion) , version)
open('version.h.in', 'w').write(version)

cppInsightsDockerBaseFile = '../cppinsights-docker-base/Dockerfile'

print(' - Generating CHANGELOG.md')
os.system('gren changelog --override --username=andreasfertig --repo=cppinsights %s...continous' %(oldInsightsVersion))

cmd = ['gren', 'changelog', '--override', '--username=andreasfertig', '--repo=cppinsights', '%s...continous' %(oldInsightsVersion)]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
print(f' - Updating cppinsights-docker-base ({cppInsightsDockerBaseFile})')

if 0 != p.returncode:
print('ERR: gren failed')
print(stderr)
return 1
dockerFile = open(cppInsightsDockerBaseFile, 'r').read()
dockerFile = re.sub(r'(ENV\s+CLANG_VERSION=)([0-9]+)', r'\g<1>%s' %(newClangStable), dockerFile)
open(cppInsightsDockerBaseFile, 'w').write(dockerFile)

changeLog = open('CHANGELOG.md', 'r').read()
changeLog = re.sub('(## Continuous build.*?---)\n', '', changeLog, flags=re.DOTALL)
open('CHANGELOG.md', 'w').write(changeLog)

gitTag = 'v_%s' %(oldInsightsVersion)
print(' - Tagging %s' %(gitTag))
gitTag = f'v_{oldInsightsVersion}'
print(f' - Tagging {gitTag}')

#cmd = ['git', 'tag', '-a', '-m', gitTag, gitTag, 'main']
cmd = ['git', 'tag', gitTag, 'main']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
Expand All @@ -85,13 +75,8 @@ def main():
print(stderr)
return 1

cppInsightsDockerBaseFile = '../cppinsights-docker-base/Dockerfile'

print(' - Updating cppinsights-docker-base (%s)' %(cppInsightsDockerBaseFile))

dockerFile = open(cppInsightsDockerBaseFile, 'r').read()
dockerFile = re.sub(r'(ENV\s+CLANG_VERSION=)([0-9]+)', r'\g<1>%s' %(newClangStable), dockerFile)
open(cppInsightsDockerBaseFile, 'w').write(dockerFile)
print(' - Push tag:')
print(f' git push origin {gitTag}')
#------------------------------------------------------------------------------

main()
Expand Down

0 comments on commit 66cf8b2

Please sign in to comment.