-
Notifications
You must be signed in to change notification settings - Fork 33
131 lines (113 loc) · 5.45 KB
/
create_release.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
on:
push:
branches:
- "master"
name: Create Release
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: "Get current version"
uses: oprypin/find-latest-tag@v1
with:
repository: ${{ github.repository }} # The repository to scan.
releases-only: true # We know that all relevant tags have a GitHub release for them.
id: acme2certifier_ver # The step ID to refer to later.
- name: Checkout code
uses: actions/checkout@v4
- name: Retrieve Version from version.py
run: |
echo APP_NAME=$(echo ${{ github.repository }} | awk -F / '{print $2}') >> $GITHUB_ENV
echo TAG_NAME=$(cat acme_srv/version.py | grep -i __version__ | head -n 1 | sed 's/__version__ = //g' | sed s/\'//g) >> $GITHUB_ENV
- run: echo "Repo is at version ${{ steps.acme2certifier_ver.outputs.tag }}"
- run: echo "APP tag is ${{ env.APP_NAME }}"
- run: echo "Latest tag is ${{ env.TAG_NAME }}"
- name: Retrieve dbversion numbers from version.py and fixture.xml
run: |
echo DB_VERSION=$(cat acme_srv/version.py | grep -i __dbversion__ | head -n 1 | sed 's/__dbversion__ = //g' | sed s/\'//g) >> $GITHUB_ENV
echo FIXTURE_VERSION=$(awk '/name: dbversion/{getline; print $2}' examples/django/acme_srv/fixture/status.yaml | tr -d "'") >> $GITHUB_ENV
- run: echo "db verion is ${{ env.DB_VERSION }}"
- run: echo "fixture verion is ${{ env.FIXTURE_VERSION }}"
- name: Check fixture version
if: env.DB_VERSION != env.FIXTURE_VERSION
run: |
echo "Fixture version is not equal to db version"
exit 1
- name: Create Release
id: create_release
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.TAG_NAME }}
release_name: ${{ env.APP_NAME }} ${{ env.TAG_NAME }}
body: |
[Changelog](https://github.com/grindsa/acme2certifier/blob/master/CHANGES.md)
draft: false
prerelease: false
- name: update version number in spec file
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
run: |
sudo sed -i "s/__version__/${{ env.TAG_NAME }}/g" examples/install_scripts/rpm/acme2certifier.spec
sudo sed -i "s/\/var\/www\/acme2certifier\/volume/\/etc\/nginx/g" examples/nginx/nginx_acme_srv_ssl.conf
git config --global user.email "grindelsack@gmail.com"
git config --global user.name "rpm update"
git add examples/nginx
git commit -a -m "rpm update"
- name: build RPM package
id: rpm_build
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
uses: grindsa/rpmbuild@alma9
with:
spec_file: "examples/install_scripts/rpm/acme2certifier.spec"
- name: Upload Release Source-RPM
id: upload-srpm
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.rpm_build.outputs.source_rpm_path }}
asset_name: ${{ steps.rpm_build.outputs.source_rpm_name }}
asset_content_type: ${{ steps.rpm_build.outputs.rpm_content_type }}
- name: Upload Release RPM
id: upload-rpm
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.rpm_build.outputs.rpm_dir_path }}noarch/acme2certifier-${{ env.TAG_NAME }}-1.0.noarch.rpm
asset_name: acme2certifier-${{ env.TAG_NAME }}-1.0.noarch.rpm
asset_content_type: ${{ steps.rpm_build.outputs.rpm_content_type }}
- name: Prepare deb packaging environment
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
run: |
sudo apt-get -y install build-essential fakeroot dpkg-dev devscripts debhelper
rm setup.py
cp -R examples/install_scripts/debian ./
sudo sed -i "s/__version__/${{ env.TAG_NAME }}/g" debian/changelog
cd ../
tar cvfz ../acme2certifier_${{ env.TAG_NAME }}.orig.tar.gz ./
- name: "[ BUILD ] build debian package"
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
run: |
dpkg-buildpackage -uc -us
# dpkg -c ../acme2certifier_${{ env.TAG_NAME }}-1_all.deb
cp ../acme2certifier_${{ env.TAG_NAME }}-1_all.deb "$(pwd)/acme2certifier_${{ env.TAG_NAME }}-1_all.deb"
ls -la
- name: Upload Release deb
id: upload-deb
if: steps.acme2certifier_ver.outputs.tag != env.TAG_NAME
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: acme2certifier_${{ env.TAG_NAME }}-1_all.deb
asset_name: acme2certifier_${{ env.TAG_NAME }}-1_all.deb
asset_content_type: application/vnd.debian.binary-package