Skip to content

Commit 66cf8b2

Browse files
Merge pull request #690 from andreasfertig/ghReleaseWorkflow
Support for automatically building a GitHub release.
2 parents a2a5015 + 46b1f35 commit 66cf8b2

3 files changed

Lines changed: 41 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
branches-ignore:
55
- 'continuous'
6+
tags:
7+
- 'v_*'
68

79
pull_request:
810
branches-ignore:
@@ -689,12 +691,27 @@ jobs:
689691
#------------------------------------------------------------------------------
690692
deploy:
691693
needs: [build, docker, in-source-tree]
692-
if: github.ref == 'refs/heads/main'
694+
if: ${{ (github.ref == 'refs/heads/main') || contains(github.ref, 'refs/tags/v_') }}
693695
name: Final Deploy
694696
continue-on-error: false
695697
runs-on: ubuntu-22.04
696698

697699
steps:
700+
- name: Get release info
701+
id: release_info
702+
shell: bash
703+
run: |
704+
tag_name=""
705+
706+
if [[ "${{ github.ref }}" == *"refs/tags/v_"* ]]; then
707+
tag_name="${{ github.ref_name }}"
708+
else
709+
tag_name="continuous"
710+
fi
711+
712+
echo "Tag: ${tag_name}"
713+
echo "tag_name=${tag_name}" >> $GITHUB_OUTPUT
714+
698715
- uses: actions/checkout@v4
699716
with:
700717
path: cppinsights
@@ -720,21 +737,21 @@ jobs:
720737
shell: bash
721738
run: |
722739
cd ${GITHUB_WORKSPACE}/cppinsights
723-
gren changelog --generate --override --username=andreasfertig --repo=cppinsights -t continuous..`git tag --sort=-creatordate | grep -v continuous | head -n 1 ` -c .github/grenrc.json
740+
gren changelog --generate --override --username=andreasfertig --repo=cppinsights -t ${{ steps.release_info.outputs.tag_name }} --limit 1 -c .github/grenrc.json
724741
sed -in '1,4d' CHANGELOG.md
725742
726-
- name: Create Release
743+
- name: Create release
727744
uses: ncipollo/release-action@v1
728745
with:
729746
artifacts: "/home/runner/binaries/insights-artifact-*/insights-*"
730747
token: ${{ secrets.GITHUB_TOKEN }}
731748
bodyFile: "${{ github.workspace }}/cppinsights/CHANGELOG.md"
732749
allowUpdates: true
733750
artifactErrorsFailBuild: true
734-
name: continuous
735-
prerelease: true
751+
name: ${{ steps.release_info.outputs.tag_name }}
752+
prerelease: ${{ steps.release_info.outputs.tag_name }} == 'continuous'
736753
removeArtifacts: true
737-
tag: continuous
754+
tag: ${{ steps.release_info.outputs.tag_name }}
738755
generateReleaseNotes: false
739756

740757
- name: Upload docs to gh-pages

scripts/llvm-coverage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#! /usr/bin/env python3
2+
#
3+
#
4+
# C++ Insights, copyright (C) by Andreas Fertig
5+
# Distributed under an MIT license. See LICENSE for details
6+
#
27
#------------------------------------------------------------------------------
38

49
import os

scripts/prepare-release.py

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
def main():
1515
versionH = open('version.h.in', 'r').read()
1616

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

2222

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

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

4645

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

5251

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

57+
cppInsightsDockerBaseFile = '../cppinsights-docker-base/Dockerfile'
5858

59-
print(' - Generating CHANGELOG.md')
60-
os.system('gren changelog --override --username=andreasfertig --repo=cppinsights %s...continous' %(oldInsightsVersion))
61-
62-
cmd = ['gren', 'changelog', '--override', '--username=andreasfertig', '--repo=cppinsights', '%s...continous' %(oldInsightsVersion)]
63-
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
64-
stdout, stderr = p.communicate()
59+
print(f' - Updating cppinsights-docker-base ({cppInsightsDockerBaseFile})')
6560

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

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

75-
gitTag = 'v_%s' %(oldInsightsVersion)
76-
print(' - Tagging %s' %(gitTag))
66+
gitTag = f'v_{oldInsightsVersion}'
67+
print(f' - Tagging {gitTag}')
7768

78-
#cmd = ['git', 'tag', '-a', '-m', gitTag, gitTag, 'main']
7969
cmd = ['git', 'tag', gitTag, 'main']
8070
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8171
stdout, stderr = p.communicate()
@@ -85,13 +75,8 @@ def main():
8575
print(stderr)
8676
return 1
8777

88-
cppInsightsDockerBaseFile = '../cppinsights-docker-base/Dockerfile'
89-
90-
print(' - Updating cppinsights-docker-base (%s)' %(cppInsightsDockerBaseFile))
91-
92-
dockerFile = open(cppInsightsDockerBaseFile, 'r').read()
93-
dockerFile = re.sub(r'(ENV\s+CLANG_VERSION=)([0-9]+)', r'\g<1>%s' %(newClangStable), dockerFile)
94-
open(cppInsightsDockerBaseFile, 'w').write(dockerFile)
78+
print(' - Push tag:')
79+
print(f' git push origin {gitTag}')
9580
#------------------------------------------------------------------------------
9681

9782
main()

0 commit comments

Comments
 (0)