-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (100 loc) · 3.47 KB
/
bump-version-and-create-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
name: Bump version and create release
on:
pull_request:
types:
- closed
branches:
- main
jobs:
compute-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_tag: ${{ steps.bump_version.outputs.new_tag }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Read version from file
run: |
# Read the version from the version file, only store the number (without the 'v')
INITIAL_VERSION=$(source version && echo ${VERSION#v})
echo "Current version: $INITIAL_VERSION"
echo "INITIAL_VERSION=${INITIAL_VERSION}" >> $GITHUB_ENV
- name: Bump version
id: bump_version
uses: anothrNick/github-tag-action@v1
env:
DEFAULT_BUMP: minor
DRY_RUN: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INITIAL_VERSION: ${{ env.INITIAL_VERSION }}
WITH_V: true
update-version-file:
needs: compute-version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Update version file with new version
run: |
echo "New version: ${{ needs.compute-version.outputs.new_tag }}"
echo "VERSION=${{ needs.compute-version.outputs.new_tag }}" > version
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add version
git commit -m "chore: update version file to ${{ needs.compute-version.outputs.new_tag }}"
git push
- name: Push new tag
run: |
git tag ${{ needs.compute-version.outputs.new_tag }}
git push origin ${{ needs.compute-version.outputs.new_tag }}
create-release:
needs: [compute-version, update-version-file]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repository and pull the new tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.compute-version.outputs.new_tag }}
- name: Build release packages
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: |
release_builder
target: release
- name: Copy release packages
run: |
mkdir -p /tmp/artifacts/
docker run --rm -v /tmp/artifacts:/tmp/artifacts release_builder cp -r /release /tmp/artifacts/
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "/tmp/artifacts/release/*"
tag: ${{ needs.compute-version.outputs.new_tag }}
body: ${{ github.event.pull_request.body }}
build-and-run-release-tests:
needs: [compute-version, create-release]
runs-on: ubuntu-latest
steps:
- name: Build release test Docker image
uses: docker/build-push-action@v6
with:
build-args: |
RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/util_caching/releases/download/${{ needs.compute-version.outputs.new_tag }}
push: false
tags: release_tester
target: release_test
- name: Run unit tests with/against released version
run: |
docker run --rm release_tester