-
Notifications
You must be signed in to change notification settings - Fork 8
174 lines (156 loc) · 6.31 KB
/
push.yml
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Intel Corporation
name: Tag/Publish Release
on:
push:
branches:
- main
jobs:
# CAUTION: Other actions depend on this name "tag-github"
tag-github:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.version-change.outputs.changed }}
version: ${{ steps.version-change.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changes
id: version-file
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep VERSION; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "VERSION file was not changed"
fi
- name: Validate change in version file
id: version-change
if: steps.version-file.outputs.changed == 'true'
run: |
version=$(cat VERSION)
echo "version=$version"
validate="^[0-9]+\.[0-9]+\.[0-9]+$"
if [[ $version =~ $validate ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
else
echo "Version change not for release"
fi
- name: Create release using REST API
if: steps.version-change.outputs.changed == 'true'
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_OMEC_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d '{
"tag_name": "${{ steps.version-change.outputs.version }}",
"target_commitish": "${{ github.event.repository.default_branch }}",
"name": "${{ steps.version-change.outputs.version }}",
"draft": false,
"prerelease": false,
"generate_release_notes": true
}'
publish:
runs-on: ubuntu-latest
needs: tag-github
if: github.repository_owner == 'omec-project'
env:
CHARTS_REPO_URL: https://charts.aetherproject.org
CHARTS_DIR: charts
REF_CHARTS_DIR: charts-ref
UMBRELLA_CHARTS: ./sdcore-helm-charts
steps:
- uses: actions/checkout@v4
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: latest
token: ${{ secrets.GH_OMEC_PAT }}
- name: Get current Index.yaml
run: |
rm -rf ${{ env.REF_CHARTS_DIR }} && mkdir -p ${{ env.REF_CHARTS_DIR }}
curl -o ${{ env.REF_CHARTS_DIR }}/index.yaml ${{ env.CHARTS_REPO_URL }}/index.yaml
- name: Find all Charts and Package them
run: |
rm -rf ${{ env.CHARTS_DIR }} && mkdir -p ${{ env.CHARTS_DIR }}
for dir in $(find . -maxdepth 1 -mindepth 1 -type d); do
if [[ -f "$dir/Chart.yaml" ]] && [[ "$dir" != ${{ env.UMBRELLA_CHARTS }} ]]; then
echo "Packaging charts for: $dir"
helm dependency update "$dir"
helm package "$dir" --destination ${{ env.CHARTS_DIR }}
fi
done
helm repo index ${{ env.CHARTS_DIR }} --url ${{ env.CHARTS_REPO_URL }} --merge ${{ env.REF_CHARTS_DIR }}/index.yaml
- name: Remove not "updated" local Charts (version has not changed)
working-directory: ${{ env.CHARTS_DIR }}
run: |
for file in *.tgz; do
if grep -q "${{ env.CHARTS_REPO_URL }}/$file" "../${{ env.REF_CHARTS_DIR }}/index.yaml"; then
echo "Not publishing $file because it is already in ${{ env.CHARTS_REPO_URL }}/index.yaml"
rm $file
fi
done
- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -avh
path: ${{ env.CHARTS_DIR }}/
remote_path: /srv/sites/charts.aetherproject.org/
remote_host: static.opennetworking.org
remote_user: ${{ secrets.JENKINS_USERNAME }}
remote_key: ${{ secrets.JENKINS_SSHKEY }}
remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }}
- name: Get current Index.yaml
run: |
rm -rf ${{ env.REF_CHARTS_DIR }} && mkdir -p ${{ env.REF_CHARTS_DIR }}
curl -o ${{ env.REF_CHARTS_DIR }}/index.yaml ${{ env.CHARTS_REPO_URL }}/index.yaml
- name: Find all Charts and Package them
run: |
rm -rf ${{ env.CHARTS_DIR }} && mkdir -p ${{ env.CHARTS_DIR }}
echo "Packaging charts for: ${{ env.UMBRELLA_CHARTS }}"
helm dependency update "${{ env.UMBRELLA_CHARTS }}"
helm package "${{ env.UMBRELLA_CHARTS }}" --destination ${{ env.CHARTS_DIR }}
helm repo index ${{ env.CHARTS_DIR }} --url ${{ env.CHARTS_REPO_URL }} --merge ${{ env.REF_CHARTS_DIR }}/index.yaml
- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -avh
path: ${{ env.CHARTS_DIR }}/
remote_path: /srv/sites/charts.aetherproject.org/
remote_host: static.opennetworking.org
remote_user: ${{ secrets.JENKINS_USERNAME }}
remote_key: ${{ secrets.JENKINS_SSHKEY }}
remote_key_pass: ${{ secrets.JENKINS_PASSPHRASE }}
update-version:
runs-on: ubuntu-latest
needs: tag-github
if: needs.tag-github.outputs.changed == 'true'
steps:
- uses: actions/checkout@v4
- name: Increment version
run: |
version=${{ needs.tag-github.outputs.version }}
IFS='.' read -r major minor patch <<< "$version"
minor_update=$((minor+1))
NEW_VERSION="$major.$minor_update.0-dev"
echo $NEW_VERSION > VERSION
echo "Updated version: $NEW_VERSION"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_OMEC_PAT }}
commit-message: Update version
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
signoff: true
branch: version-update
delete-branch: true
title: Update version
body: |
Update VERSION file
add-paths: |
VERSION