Skip to content

Build and Release

Build and Release #17

name: Build and Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
environment:
description: 'Environment to run tests against'
type: environment
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libncurses5-dev
pip install -r requirements.txt
- name: Get latest release tag
id: get_latest_tag
run: |
latest_tag=$(git tag -l | sort -V | tail -n 1)
if [ -z "$latest_tag" ]; then
echo "::set-output name=tag::v1.0.2" # Set a default tag if no tags are found
else
echo "::set-output name=tag::$latest_tag"
fi
- name: Increment version
id: increment_version
run: echo "::set-output name=next_version::$(python -c "version = '${{ steps.get_latest_tag.outputs.tag }}'.split('.'); version[-1] = str(int(version[-1]) + 1); print('.'.join(version))")"
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.increment_version.outputs.next_version }}
release_name: Release ${{ steps.increment_version.outputs.next_version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/main
asset_name: Console-Weather-App
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Cleanup
run: rm -r build