forked from eclipse-tractusx/tractusx-edc
-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (125 loc) · 5.22 KB
/
draft-release.yaml
File metadata and controls
139 lines (125 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#################################################################################
# Copyright (c) 2025 Cofinity-X GmbH
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#################################################################################
---
name: "Draft Release"
run-name: "Draft ${{ inputs.version }} from ${{ github.ref_name }}"
on:
workflow_dispatch:
inputs:
version:
description: 'The version you want to release.'
required: true
jobs:
validate-and-prepare:
name: "Validate that tag does not already exist and prepare branch"
runs-on: ubuntu-latest
if: ${{ github.ref_name == 'main' || github.ref_type == 'tag' }}
outputs:
branch_name: ${{ steps.resolve_branch.outputs.branch_name }}
is_official_release: ${{ steps.validation.outputs.is_official_release }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- id: validation
name: "Validations"
shell: bash
run: |
shopt -s nocasematch
IFS=.- read -r MAJOR_INPUT MINOR_INPUT PATCH_INPUT SNAPSHOT_INPUT<<<"${{ inputs.version }}"
VERSION=$(grep "version" gradle.properties | awk -F= '{print $2}')
IFS=.- read -r MAJOR MINOR PATCH SNAPSHOT<<<"$VERSION"
# Release Candidate
if [[ ! -z $SNAPSHOT_INPUT ]] then
if [[ -z $SNAPSHOT ]] then
echo "You want to build a release candidate, but the selected commit is neither on main nor a release candidate."
exit 1
fi
# Bugfix
elif [[ -z $SNAPSHOT_INPUT && $PATCH_INPUT != '0' ]] then
if [[ ${{ github.ref_type }} != 'tag' || ! -z $SNAPSHOT ]] then
echo "You want to build a bugfix, but the selected commit is neither a bugfix nor an official release"
exit 1
fi
# Official Release
elif [[ -z $SNAPSHOT_INPUT && $PATCH_INPUT == '0' ]] then
if [[ ${{ github.ref_type }} != 'tag' || $SNAPSHOT != *rc* ]] then
echo "You want to build an official release, but the selected commit is not a release candidate"
exit 1
fi
fi
if [[ ! -z $SNAPSHOT_INPUT ]] then
echo "is_official_release=false" >> "$GITHUB_OUTPUT"
else
echo "is_official_release=true" >> "$GITHUB_OUTPUT"
fi
- id: check-tag
name: "Check if tag exists"
run: |-
tag=$(git tag -l ${{ inputs.version }})
if [ ! -z $tag ];
then
echo "Tag ${{ inputs.version }} already exists! Please choose another tag."
exit 1
fi
- id: resolve_branch
name: "Resolve branch name"
run: |
echo "branch_name=release/${{ inputs.version }}" >> "$GITHUB_OUTPUT"
draft-new-release:
name: "Draft a new release"
runs-on: ubuntu-latest
needs: validate-and-prepare
permissions:
contents: write
packages: write
pages: write
steps:
- uses: actions/checkout@v6
- name: Create Release branch
run: git checkout -b ${{ needs.validate-and-prepare.outputs.branch_name }}
- uses: ./.github/actions/setup-java
- name: Version and Chart Updates
uses: ./.github/actions/update-version-and-charts
with:
version: ${{ inputs.version }}
bump_version: "false"
- name: Push new branch
run: git push origin ${{ needs.validate-and-prepare.outputs.branch_name }}
- name: Check dependencies before release
uses: ./.github/actions/generate-and-check-dependencies
with:
run: ${{ needs.validate-and-prepare.outputs.is_official_release == 'true' && 'strict' || 'standard' }}
- name: Replace published DEPENDENCIES file link in NOTICE with the one just created
run: sed -i "s#\[DEPENDENCIES\]\(.*\)#\[DEPENDENCIES\]\(DEPENDENCIES\)#g" NOTICE.md
- name: Commit DEPENDENCIES changes
shell: bash
run: |
if git diff --quiet -- DEPENDENCIES; then
echo "No changes in DEPENDENCIES, skipping commit."
exit 0
fi
git add DEPENDENCIES
git config user.name "eclipse-tractusx-bot"
git config user.email "tractusx-bot@eclipse.org"
git commit --message "Update DEPENDENCIES file"
git push origin ${{ needs.validate-and-prepare.outputs.branch_name }}
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT