Skip to content

[wf] push images of latest and 2nd latest version #255

[wf] push images of latest and 2nd latest version

[wf] push images of latest and 2nd latest version #255

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 "[email protected]"
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