Release #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- 'v*.*' | |
inputs: | |
create_release: | |
description: 'Create Release' | |
required: false | |
default: 'true' | |
# Allows to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
create_release: | |
description: 'Create Release' | |
required: false | |
default: 'draft' | |
jobs: | |
build-artifacts: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
version_num: ${{ steps.version.outputs.version_num }} | |
archive_filename_tar: mbuspico_${{ steps.version.outputs.version }}.tar.gz | |
archive_filename_zip: mbuspico_${{ steps.version.outputs.version }}.zip | |
archive_filename_python: mbuspico_python_${{ steps.version.outputs.version }}.zip | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: version | |
run: | | |
ver=${VERSION_REF##*/} | |
if [[ "$ver" =~ ^v([0-9]+).([0-9]+) ]]; then | |
echo "version=$ver" >> $GITHUB_OUTPUT | |
echo "version_num=${ver:1}" >> $GITHUB_OUTPUT | |
else | |
echo "version=v0.0" >> $GITHUB_OUTPUT | |
echo "version_num=0.0" >> $GITHUB_OUTPUT | |
fi | |
env: | |
VERSION_REF: ${{ github.ref }} | |
shell: bash | |
id: version | |
- name: Create archive tar | |
run: | | |
mkdir -p dist/zip | |
tar czvf dist/$ARCHIVE_NAME --exclude-vcs --exclude-vcs-ignore --exclude='dist' . | |
tar xzvf dist/$ARCHIVE_NAME -C dist/zip | |
env: | |
ARCHIVE_NAME: mbuspico.tar.gz | |
id: create-archive-tar | |
- name: Upload tar-archive artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifact-archive-tar | |
path: dist/mbuspico.tar.gz | |
- name: Create archive zip | |
run: | | |
apt update && apt install -y zip | |
cd dist/zip | |
zip -r ../$ARCHIVE_NAME . | |
env: | |
ARCHIVE_NAME: mbuspico.zip | |
id: create-archive-zip | |
- name: Upload zip-archive artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifact-archive-zip | |
path: dist/mbuspico.zip | |
- name: Create archive python | |
run: | | |
cd python | |
zip -r ../dist/$ARCHIVE_NAME . | |
env: | |
ARCHIVE_NAME: python.zip | |
id: create-python-zip | |
- name: Upload ypthon archive artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifact-archive-python | |
path: dist/python.zip | |
docker: | |
runs-on: ubuntu-latest | |
needs: | |
- build-artifacts | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
file: docker/python-run.Dockerfile | |
push: true | |
tags: ravenworx/mbuspico:latest, ravenworx/mbuspico:${{needs.build-artifacts.outputs.version_num}} | |
create-release: | |
runs-on: ubuntu-latest | |
needs: | |
- build-artifacts | |
if: ${{ needs.build-artifacts.outputs.version != 'v0.0' || (github.event.inputs && contains('true draft', github.event.inputs.create_release)) }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Generate Changelog | |
id: changelog | |
uses: metcalfc/changelog-generator@v4.0.1 | |
with: | |
myToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
id: create-release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: MBusPico ${{needs.build-artifacts.outputs.version}} | |
body: | | |
${{ steps.changelog.outputs.changelog }} | |
draft: ${{ github.event.inputs && github.event.inputs.create_release == 'draft' }} | |
prerelease: false | |
- name: Download tar-archive artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact-archive-tar | |
path: dist | |
- name: Download zip-archive artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact-archive-zip | |
path: dist | |
- name: Download python artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact-archive-python | |
path: dist | |
- name: Upload archive tar artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: dist/mbuspico.tar.gz | |
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_tar }} | |
asset_content_type: application/gzip | |
- name: Upload archive zip artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: dist/mbuspico.zip | |
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_zip }} | |
asset_content_type: application/zip | |
- name: Upload python artifact | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: dist/python.zip | |
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_python }} | |
asset_content_type: application/zip |