-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (140 loc) · 5.31 KB
/
ci.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
138
139
140
141
142
143
144
name: CI
on:
push:
branches: [main]
pull_request:
release:
types: [published]
jobs:
tlint:
name: Lint checks
runs-on: ubuntu-20.04
container:
image: ghcr.io/trento-project/tlint:latest
volumes:
- ${{ github.workspace }}:/data
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run TLint
run: "/home/tlint/tlint lint -f /data/checks"
obs-commit-rpm:
name: Commit to OBS to generate a RPM package
needs: [tlint]
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
container:
image: ghcr.io/trento-project/continuous-delivery:main
env:
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASS: ${{ secrets.OBS_PASS }}
OBS_PROJECT: ${{ secrets.OBS_PROJECT }}
OSC_CHECKOUT_DIR: /tmp/trento-checks-package
REPOSITORY: ${{ github.repository }}
FOLDER: packaging/suse/rpm
options: -u 0:0
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure OSC
run: |
mkdir -p $HOME/.config/osc
cp /home/osc/.config/osc/oscrc $HOME/.config/osc
/scripts/init_osc_creds.sh
- name: Prepare _service file
run: |
git config --global --add safe.directory /__w/checks/checks
VERSION=$(./hack/get_version_from_git.sh)
sed -i 's~%%REVISION%%~${{ github.sha }}~' $FOLDER/_service && \
sed -i 's~%%REPOSITORY%%~'"${REPOSITORY}"'~' $FOLDER/_service && \
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/_service
- name: Checkout and prepare OBS package
run: |
osc checkout $OBS_PROJECT trento-checks -o $OSC_CHECKOUT_DIR
cp $FOLDER/_service $OSC_CHECKOUT_DIR
cp $FOLDER/trento-checks.spec $OSC_CHECKOUT_DIR
rm -vf $OSC_CHECKOUT_DIR/*.tar.gz
pushd $OSC_CHECKOUT_DIR
osc service manualrun
rm -vf $OSC_CHECKOUT_DIR/*.tgz
- name: Prepare trento-checks.changes file
# The .changes file is updated only in release creation. This current task should be improved
# in order to add the current rolling release notes
if: github.event_name == 'release'
run: |
git config --global --add safe.directory /__w/checks/checks
VERSION=$(./hack/get_version_from_git.sh)
TAG=$(echo $VERSION | cut -f1 -d+)
hack/gh_release_to_obs_changeset.py $REPOSITORY -a [email protected] -t $TAG -f $OSC_CHECKOUT_DIR/trento-checks.changes
- name: Commit changes into OBS
run: |
pushd $OSC_CHECKOUT_DIR
osc ar
osc commit -m "GitHub Actions automated update to reference ${{ github.sha }}"
obs-commit-image:
name: Commit to OBS to generate a container image
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/main' || github.event_name == 'release'
needs: [tlint]
container:
image: ghcr.io/trento-project/continuous-delivery:main
env:
FOLDER: packaging/suse/container
NAME: trento-checks-image
OBS_PASS: ${{ secrets.OBS_PASS }}
OBS_PROJECT: ${{ secrets.OBS_PROJECT }}
OBS_USER: ${{ secrets.OBS_USER }}
OSC_CHECKOUT_DIR: /tmp/trento-checks-image
REPOSITORY: ${{ github.repository }}
options: -u 0:0
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions-ecosystem/action-get-latest-tag@v1
id: latest-tag
with:
semver_only: true
initial_version: 0.0.1
- name: Configure OSC
run: |
mkdir -p $HOME/.config/osc
cp /home/osc/.config/osc/oscrc $HOME/.config/osc
/scripts/init_osc_creds.sh
- name: Prepare .changes file
# The .changes file is updated only in release creation. This current task should be improved
# in order to add the current rolling release notes
if: github.event_name == 'release'
run: |
CHANGES_FILE=$NAME.changes
osc checkout $OBS_PROJECT $NAME $CHANGES_FILE
mv $CHANGES_FILE $FOLDER
VERSION=${{ steps.latest-tag.outputs.tag }}
hack/gh_release_to_obs_changeset.py $REPOSITORY -a [email protected] -t $VERSION -f $FOLDER/$CHANGES_FILE
- name: Set version
run: |
git config --global --add safe.directory /__w/checks/checks
VERSION=$(./hack/get_version_from_git.sh)
# "+" character is not allowed in OBS dockerfile version strings
VERSION=${VERSION//[+]/-}
sed -i 's~%%VERSION%%~'"${VERSION}"'~' $FOLDER/Dockerfile
- name: Commit on OBS
run: |
OBS_PACKAGE=$OBS_PROJECT/$NAME
osc checkout $OBS_PACKAGE -o $OSC_CHECKOUT_DIR
cp -r $FOLDER/* $OSC_CHECKOUT_DIR
tar --transform 's,^./,/checks/,' -zcvf $OSC_CHECKOUT_DIR/checks.tar.gz --exclude=./.git ./*
cd $OSC_CHECKOUT_DIR
osc ar
osc commit -m "New development version of $NAME released"