Skip to content

move to github actions and build jammy package #2

move to github actions and build jammy package

move to github actions and build jammy package #2

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Release
on:
pull_request:
paths-ignore:
- 'docs/**'
push:
branches:
- master
paths-ignore:
- 'docs/**'
release:
types:
- created
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEBIAN_FRONTEND: noninteractive
LANG: C.UTF-8
jobs:
build_docker_image:
name: Build docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker build -t convertit:latest .
- name: Upload image
uses: ishworkh/docker-image-artifact-upload@v1
with:
image: "convertit:latest"
build_deb_22_04:
name: Build 22.04 package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare debian 22.04 versioning
run: |
sed -i 's/+dev/.ubuntu22.04~dev'$GITHUB_RUN_ID'/' debian/changelog
sed -i 's/convertit (\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)) RELEASED;/convertit (\1.ubuntu22.04\2) jammy;/' debian/changelog
- name: Building package debian 22.04
run: |
DISTRO=ubuntu:jammy make build_deb
cp ./dpkg/*.deb /home/runner/work/convertit/
- name: Archive package artifact
uses: actions/upload-artifact@v3
with:
name: debian-22.04
path: |
/home/runner/work/Geotrek-admin/*.deb
build_deb_20_04:
name: Build 20.04 package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare debian 20.04 versioning
run: |
sed -i 's/+dev/.ubuntu20.04~dev'$GITHUB_RUN_ID'/' debian/changelog
sed -i 's/convertit (\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)) RELEASED;/convertit (\1.ubuntu20.04\2) focal;/' debian/changelog
- name: Building package debian 18.04
run: |
DISTRO=ubuntu:focal make build_deb
cp ./dpkg/*.deb /home/runner/work/convertit/
- name: Archive package artifact
uses: actions/upload-artifact@v3
with:
name: debian-20.04
path: |
/home/runner/work/Geotrek-admin/*.deb
deploy:
name: Publish (on release only)
runs-on: ubuntu-latest
needs: [ build_docker_image, build_deb_22_04, build_deb_20_04 ]
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
steps:
- uses: actions/checkout@v3
- name: Download 22.04 debian artifact
uses: actions/download-artifact@v3
with:
name: debian-22.04
- name: Download 20.04 debian artifact
uses: actions/download-artifact@v3
with:
name: debian-20.04
- name: Download docker image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "convertit:latest"
- name: Attach debian packages as release binaries
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: '*.deb'
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish Docker image (v2 and latest)
run: |
if [[ "${{ github.ref }}" == *"dev"* ]]; then
export DOCKER_TAG=dev
else
docker tag convertit:latest makinacorpus/convertit:$(cat VERSION)
docker push makinacorpus/convertit:$(cat VERSION)
export DOCKER_TAG=latest
fi
docker tag convertit:latest makinacorpus/convertit:$DOCKER_TAG
docker push makinacorpus/convertit:$DOCKER_TAG
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Publish debian packages
run: |
if [[ "${{ github.ref }}" == *"dev"* ]]; then
export DEB_COMPONENT=dev
else
export DEB_COMPONENT=main
fi
echo "${{ github.ref }} : Publishing as $DEB_COMPONENT package"
scp -P ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no /home/runner/work/convertit/convertit/convertit_*_amd64.deb ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/srv/packages/incoming/$DEB_COMPONENT/
if [[ "${{ github.ref }}" == *"dev"* ]]; then
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make bionic_dev -C /srv/packages
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make focal_dev -C /srv/packages
else
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make bionic_main -C /srv/packages
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make focal_main -C /srv/packages
fi