-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb40ee1
commit 1edeb29
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
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 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: version | ||
run: | | ||
ver=${VERSION_REF##*/} | ||
if [[ "$ver" =~ ^v([0-9]+).([0-9]+) ]]; then | ||
echo "::set-output name=version::$ver" | ||
echo "::set-output name=version_num::${ver:1}" | ||
else | ||
echo "::set-output name=version::v0.0" | ||
echo "::set-output name=version_num::0.0" | ||
fi | ||
env: | ||
VERSION_REF: ${{ github.ref }} | ||
shell: bash | ||
id: version | ||
|
||
- name: Create archive tar | ||
run: | | ||
tar czvf dist/$ARCHIVE_NAME --exclude-vcs --exclude-vcs-ignore --exclude dist . | ||
mkdir dist/zip | ||
tar xzvf ../dist/$ARCHIVE_NAME -C dist/zip | ||
env: | ||
ARCHIVE_NAME: ${{ steps.version.outputs.archive_filename_tar }} | ||
id: create-archive-tar | ||
- name: Upload tar-archive artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifact-archive-tar | ||
path: dist/${{ steps.version.outputs.archive_filename_tar }} | ||
|
||
- name: Create archive zip | ||
run: | | ||
apt update && apt install -y zip | ||
cd dist/zip | ||
zip -r ../mbuspico_v0.0.zip . | ||
env: | ||
ARCHIVE_NAME: ${{ steps.version.outputs.archive_filename_zip }} | ||
id: create-archive-zip | ||
- name: Upload zip-archive artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifact-archive-zip | ||
path: dist/${{ steps.version.outputs.archive_filename_zip }} | ||
|
||
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@v3.0.0 | ||
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: 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/${{ needs.build-artifacts.outputs.archive_filename_tar }} | ||
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/${{ needs.build-artifacts.outputs.archive_filename_zip }} | ||
asset_name: ${{ needs.build-artifacts.outputs.archive_filename_zip }} | ||
asset_content_type: application/zip |