1+ name : Versioned Release
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ permissions :
9+ contents : write # we need this to be able to push tags
10+ pull-requests : read
11+
12+ jobs :
13+ release_tag :
14+ name : Release version
15+ runs-on : ubuntu-24.04
16+ steps :
17+ - name : Create GitHub App token
18+ uses : actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2
19+ id : app-token
20+ with :
21+ # required
22+ app-id : 1312871
23+ private-key : ${{ secrets.OPENMCP_CI_APP_PRIVATE_KEY }}
24+
25+ - name : Checkout code
26+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
27+ with :
28+ token : ${{ steps.app-token.outputs.token }}
29+ fetch-tags : true
30+ fetch-depth : 0
31+ submodules : recursive
32+
33+ - name : Read and validate VERSION
34+ id : version
35+ run : |
36+ VERSION=$(task version)
37+ if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
38+ echo "Invalid version format: $VERSION"
39+ exit 1
40+ fi
41+ echo "New version: $VERSION"
42+ echo "version=$VERSION" >> $GITHUB_ENV
43+
44+ - name : Skip release if version is a dev version
45+ if : contains(env.version, '-dev')
46+ run : |
47+ echo "Skipping development version release: ${{ env.version }}"
48+ echo "SKIP=true" >> $GITHUB_ENV
49+ exit 0
50+
51+ - name : Check if VERSION is already tagged
52+ id : check_tag
53+ run : |
54+ if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
55+ echo "Tag ${{ env.version }} already exists. Skipping release."
56+ echo "SKIP=true" >> $GITHUB_ENV
57+ exit 0
58+ fi
59+ echo "Tag ${{ env.version }} doesn't exists. Proceeding with release."
60+
61+ - name : Create Git tag
62+ if : ${{ env.SKIP != 'true' }}
63+ run : |
64+ AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
65+ AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
66+ echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
67+
68+ echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
69+ echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
70+
71+ git config user.name "$AUTHOR_NAME"
72+ git config user.email "$AUTHOR_EMAIL"
73+
74+ git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
75+ git push origin "${{ env.version }}"
76+
77+ NESTED_GO_MODULES="$(task release:list-nested-modules)"
78+
79+ for MODULE in $NESTED_GO_MODULES; do
80+ git tag -a "${MODULE}/${{ env.version }}" -m "Release ${{ env.version }}"
81+ git push origin "${MODULE}/${{ env.version }}"
82+ done
83+
84+ - name : Create GitHub release
85+ if : ${{ env.SKIP != 'true' }}
86+ uses : softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
87+ with :
88+ tag_name : ${{ env.version }}
89+ name : Release ${{ env.version }}
90+ body : " "
91+ draft : true
92+ prerelease : false
93+ env :
94+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
95+
96+ - name : Push dev VERSION
97+ if : ${{ env.SKIP != 'true' }}
98+ run : |
99+ echo "${{ env.version }}-dev" > VERSION
100+
101+ sed -i -e "0,/)/{[email protected] /openmcp-project/landscaper/apis .*@github.com/openmcp-project/landscaper/apis v0.0.0-00010101000000-000000000000@}" \ 102+ go.mod
103+
104+ sed -i -e "0,/)/{[email protected] /openmcp-project/landscaper/controller-utils .*@github.com/openmcp-project/landscaper/controller-utils v0.0.0-00010101000000-000000000000@}" \ 105+ go.mod
106+
107+ sed -i -e "0,/)/{[email protected] /openmcp-project/landscaper/apis .*@github.com/openmcp-project/landscaper/apis v0.0.0-00010101000000-000000000000@}" \ 108+ controller-utils/go.mod
109+
110+ git config user.name "${{ env.AUTHOR_NAME }}"
111+ git config user.email "${{ env.AUTHOR_EMAIL }}"
112+ git add VERSION
113+ git add go.mod
114+ git add controller-utils/go.mod
115+ git commit -m "chore(release): Update VERSION to ${{ env.version }}-dev"
116+ git push origin main
0 commit comments