-
Notifications
You must be signed in to change notification settings - Fork 3
137 lines (116 loc) · 4.47 KB
/
release.yaml
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
name: release
on:
push:
tags: ["v[0-9].[0-9]+.[0-9]+"]
permissions:
contents: write
pull-requests: write
jobs:
build_foxe:
name: build_foxe
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install dependencies
run: npm install
- name: Package
run: npm run package
- name: Extract version
id: extract_version
run: |
version=$(node -p "require('./package.json').version")
echo "version=$version" >> $GITHUB_ENV
- name: Update changelog file
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin main
git checkout -b update-changelog origin/main
yarn commitizen init cz-conventional-changelog --save-dev --force --save-exact
HEADER=$(awk '/^---/{exit} {print}' CHANGELOG.md)
yarn conventional-changelog -p angular -o TEMP.md -r 0
echo "$HEADER" > CHANGELOG.md
echo "" >> CHANGELOG.md
cat TEMP.md >> CHANGELOG.md
rm TEMP.md
echo "Updated CHANGELOG.md:"
cat CHANGELOG.md
git diff || echo "No changes detected"
- name: Fetch initial commit history
id: fetch_initial_commit_history
run: |
INITIAL_COMMIT_HISTORY=$(cat initial_commit_history.md)
echo "INITIAL_COMMIT_HISTORY<<EOF" >> $GITHUB_ENV
echo "$INITIAL_COMMIT_HISTORY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Insert initial commit history
run: |
TARGET_TAG="0.0.1"
FILE="CHANGELOG.md"
INITIAL_COMMIT_HISTORY="${{ env.INITIAL_COMMIT_HISTORY }}"
if grep -q "^## $TARGET_TAG " "$FILE"; then
sed -i "/^## $TARGET_TAG /,/^## /{//!d}" "$FILE"
awk -v content="$INITIAL_COMMIT_HISTORY" -v tag="## $TARGET_TAG " '
BEGIN { found=0 }
$0 ~ tag { print; print content; found=1; next }
{ print }
END { if (!found) print "Tag header not found!" }
' "$FILE" > TEMP.md && mv TEMP.md "$FILE"
echo "Initial commit history inserted under the ## $TARGET_TAG header in $FILE."
else
echo "Tag ## $TARGET_TAG not found in $FILE."
fi
- name: Commit changelog changes
run: |
git add CHANGELOG.md
git commit -m "chore: update changelog for ${{ github.ref }}"
git push -u origin update-changelog --force
- name: Create a Pull Request to update the changelog file
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT_TOKEN }}
commit-message: "docs: update CHANGELOG for release"
branch: "update-changelog"
title: "Update CHANGELOG for new release"
body: "This pull request updates the CHANGELOG file with details of the new release."
base: "main"
delete-branch: true
- name: Create GitHub Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ASAM OSI Converter ${{ env.version }}
draft: false
prerelease: false
- name: Upload Release Asset
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: lichtblick.asam-osi-converter-${{ env.version }}.foxe
asset_name: lichtblick.asam-osi-converter-${{ env.version }}.foxe
asset_content_type: application/octet-stream
- name: Upload Changelog
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./CHANGELOG.md
asset_name: CHANGELOG.md
asset_content_type: text/markdown