Skip to content

Commit 8b9830a

Browse files
committed
added create-release github workflow
1 parent f0bbb8b commit 8b9830a

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., 1.2.3)'
8+
required: true
9+
type: string
10+
prerelease:
11+
description: 'Mark as pre-release'
12+
required: false
13+
default: false
14+
type: boolean
15+
update-major-tag:
16+
description: 'Update major version tag (e.g., 1)'
17+
required: false
18+
default: true
19+
type: boolean
20+
21+
jobs:
22+
validate:
23+
name: Validate Release
24+
runs-on: ubuntu-latest
25+
outputs:
26+
version: ${{ steps.validate.outputs.version }}
27+
version-tag: ${{ steps.validate.outputs.version-tag }}
28+
major-version: ${{ steps.validate.outputs.major-version }}
29+
minor-version: ${{ steps.validate.outputs.minor-version }}
30+
31+
steps:
32+
- name: Validate version format
33+
id: validate
34+
run: |
35+
VERSION="${{ github.event.inputs.version }}"
36+
37+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
38+
echo "::error::Invalid version format. Use 'X.Y.Z'."
39+
exit 1
40+
fi
41+
42+
# Extract version components
43+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
44+
MINOR=$(echo "$VERSION" | cut -d. -f2)
45+
46+
MAJOR_TAG="$MAJOR"
47+
MINOR_TAG="$MAJOR.$MINOR"
48+
49+
echo "version=$VERSION" >> $GITHUB_OUTPUT
50+
echo "version-tag=$VERSION" >> $GITHUB_OUTPUT
51+
echo "major-version=$MAJOR_TAG" >> $GITHUB_OUTPUT
52+
echo "minor-version=$MINOR_TAG" >> $GITHUB_OUTPUT
53+
54+
- name: Check if tag already exists
55+
run: |
56+
if git ls-remote --tags origin | grep -q "refs/tags/${{ steps.validate.outputs.version-tag }}$"; then
57+
echo "::error::Tag ${{ steps.validate.outputs.version-tag }} already exists"
58+
exit 1
59+
fi
60+
61+
run-tests:
62+
name: Run Tests
63+
runs-on: ubuntu-latest
64+
needs: validate
65+
66+
steps:
67+
- name: Run Pipelines
68+
id: run-tests
69+
run: |
70+
sh tests/run-all.sh
71+
72+
release:
73+
name: Create Release
74+
runs-on: ubuntu-latest
75+
needs: [validate, run-tests]
76+
permissions:
77+
contents: write
78+
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
with:
83+
fetch-depth: 0
84+
token: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Configure git
87+
run: |
88+
git config --local user.name "ae-actions-runner"
89+
git config --local user.email "ae-actions-runner@metaeffekt.com"
90+
91+
92+
- name: Commit version updates
93+
run: |
94+
VERSION="${{ needs.validate.outputs.version }}"
95+
VERSION_TAG="${{ needs.validate.outputs.version-tag }}"
96+
97+
git add -A
98+
99+
if ! git diff --staged --quiet; then
100+
git commit -m "Release $VERSION: Update action references from @main to @$VERSION_TAG"
101+
echo "Changes committed"
102+
else
103+
echo "No changes to commit"
104+
fi
105+
106+
- name: Create and push release tag
107+
run: |
108+
VERSION="${{ needs.validate.outputs.version }}"
109+
VERSION_TAG="${{ needs.validate.outputs.version-tag }}"
110+
111+
git tag -a "$VERSION_TAG" -m "Release $VERSION"
112+
git push origin "$VERSION_TAG"
113+
114+
echo "Created and pushed tag: $VERSION_TAG"
115+
116+
- name: Update major and minor version tags
117+
if: github.event.inputs.update-major-tag == 'true'
118+
run: |
119+
VERSION="${{ needs.validate.outputs.version }}"
120+
MAJOR_VERSION="${{ needs.validate.outputs.major-version }}"
121+
MINOR_VERSION="${{ needs.validate.outputs.minor-version }}"
122+
123+
git tag -f "$MAJOR_VERSION"
124+
git push origin "$MAJOR_VERSION" --force
125+
126+
git tag -f "$MINOR_VERSION"
127+
git push origin "$MINOR_VERSION" --force
128+
129+
- name: Create GitHub Release
130+
uses: actions/create-release@v1
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
with:
134+
tag_name: ${{ needs.validate.outputs.version-tag }}
135+
release_name: ${{ needs.validate.outputs.version }}
136+
draft: false
137+
prerelease: ${{ github.event.inputs.prerelease }}

tests/run-pipeline-001.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ mvn -f "$PROCESSORS_DIR/bootstrap_update-mirror.xml" compile -P withoutProxy \
3232
-Dmirror.archive.url="http://ae-scanner/mirror/index/index-database.zip" \
3333
-Dmirror.archive.name="index-database.zip"
3434

35+
rm -r $PROCESSORS_DIR/target # Necessary because antrun produces a target folder in processors
36+
3537
# ENRICH INVENTORY
3638
mvn -f "$PROCESSORS_DIR/advise_enrich-inventory.xml" process-resources \
3739
-Dinput.inventory="$RESOLVED_DIR/$INPUT_NAME-resolved.xlsx" \

0 commit comments

Comments
 (0)