-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (123 loc) · 4.32 KB
/
Copy pathrelease.yml
File metadata and controls
144 lines (123 loc) · 4.32 KB
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: Release workflow
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
build-archive:
name: Build archive
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Build project
run: |
cd /home/runner/work/fields/
cd fields && composer install --no-dev && cd ..
rm -rf fields/.git* fields/debian fields/tools fields/README.md fields/composer.json fields/composer.lock fields/plugin.xml
tar -zcvf fields-${{ github.ref_name }}.tgz fields
- name: Upload release
uses: actions/upload-artifact@v7
with:
name: fields-${{ github.ref_name }}.tgz
path: /home/runner/work/fields/fields-${{ github.ref_name }}.tgz
build-debian-package:
name: Build debian package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install tools
run: |
sudo apt update
sudo apt install -y build-essential dpkg-dev debhelper composer
- name: Build DEB Package
run: |
sed -i "s/CHANGEVERSION/${GITHUB_REF_NAME#v}/g" debian/rules
dpkg-buildpackage -us -uc -b
mv ../itsm-ng-plugin-fields_${GITHUB_REF_NAME#v}_all.deb "$GITHUB_WORKSPACE/itsm-ng-plugin-fields_${GITHUB_REF_NAME}_all.deb"
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Upload DEB artifact
uses: actions/upload-artifact@v7
with:
name: itsm-ng-plugin-fields_${{ github.ref_name }}_all.deb
path: ${{ github.workspace }}/itsm-ng-plugin-fields_${{ github.ref_name }}_all.deb
release:
runs-on: ubuntu-latest
needs:
- build-archive
- build-debian-package
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: ./dist
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v3
with:
files: ./dist/*
body: "New release is available"
name: ${{ github.ref_name }}
draft: false
generate_release_notes: true
upload-deb-to-server:
runs-on: ubuntu-latest
needs: release
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: ./dist
merge-multiple: true
- name: Upload DEBs to server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PORT: ${{ secrets.SSH_PORT_DEB }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -p "$SSH_PORT" "$SSH_HOST" >> ~/.ssh/known_hosts
# Définir les distributions en fonction de la version
DISTROS_DEBIAN="trixie sid"
DISTROS_UBUNTU="noble resolute"
for file in ./dist/*.deb; do
base=$(basename "$file")
echo "📦 Upload de $base vers le serveur"
scp -P "$SSH_PORT" "$file" root@"$SSH_HOST":/tmp/
# Ajout dans toutes les distributions Debian
for dist in $DISTROS_DEBIAN; do
echo "➕ Ajout de $base dans Debian $dist"
ssh -p "$SSH_PORT" root@"$SSH_HOST" \
"cd /var/www/debian && reprepro -Vb . includedeb $dist /tmp/$base"
done
# Ajout dans toutes les distributions Ubuntu
for dist in $DISTROS_UBUNTU; do
echo "➕ Ajout de $base dans Ubuntu $dist"
ssh -p "$SSH_PORT" root@"$SSH_HOST" \
"cd /var/www/ubuntu && reprepro -Vb . includedeb $dist /tmp/$base"
done
# Nettoyage
ssh -p "$SSH_PORT" root@"$SSH_HOST" "rm -f /tmp/$base"
done
create_ticket:
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Create ticket in ITSM-NG
uses: itsmng/itsm-ng_create_ticket_action@master
with:
titre: "Release fields (SaaS)"
contenu: "version: ${{ github.ref_name }} "
priority: 3
entite_id: 15
group_id: 22
api_url: "https://support.itsm-ng.com/apirest.php"
APP_TOKEN: ${{ secrets.APP_TOKEN }}
USER_TOKEN: ${{ secrets.USER_TOKEN }}