Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
name: Make Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version (Example: 1.0.0, must match 'version' in setup.py)"
required: true
default: '1.0.0'
on: workflow_dispatch

jobs:
release_create:
runs-on: ubuntu-latest

outputs:
version: ${{ steps.get_version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Bump version
run: >-
bin/bump_version.py

- name: Commit updated version.py
run: |
git config --global user.name 'github-actions'
git config --global user.email 'bot@noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git add setup.py
git commit -m "bump version" && git push || echo "No changes to commit"

- name: Get version
id: get_version
run: >-
bin/show_version.py

- name: Create GitHub release
uses: actions/create-release@v1
id: create_release

with:
draft: true
prerelease: true
release_name: ${{ github.event.inputs.version}}
tag_name: ${{ github.event.inputs.version}}
release_name: Meshtastic ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
body: |
Autogenerated by github action, developer should edit as required before publishing...
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}

publish_to_pypi:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

Expand Down Expand Up @@ -137,7 +150,7 @@ jobs:
asset_path: dist/meshtastic
asset_name: meshtastic_ubuntu
asset_content_type: application/zip

- name: Add readme.txt to release
uses: actions/upload-release-asset@v1
env:
Expand All @@ -146,7 +159,7 @@ jobs:
upload_url: ${{ needs.release_create.outputs.upload_url }}
asset_path: standalone_readme.txt
asset_name: readme.txt
asset_content_type: text/plain
asset_content_type: text/plain

build-and-publish-windows:
runs-on: windows-latest
Expand Down
25 changes: 25 additions & 0 deletions bin/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
"""Bump the version number"""

version_filename = "setup.py"

lines = None

with open(version_filename, 'r', encoding='utf-8') as f:
lines = f.readlines()

with open(version_filename, 'w', encoding='utf-8') as f:
for line in lines:
if line.lstrip().startswith("version="):
# get rid of quotes around the version
line = line.replace('"', '')
# get rid of trailing comma
line = line.replace(",", "")
# split on '='
words = line.split("=")
# split the version into parts (by period)
v = words[1].split(".")
ver = f'{v[0]}.{v[1]}.{int(v[2]) + 1}'
f.write(f' version="{ver}",\n')
else:
f.write(line)
20 changes: 20 additions & 0 deletions bin/show_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
"""Show the version number"""

version_filename = "setup.py"

lines = None

with open(version_filename, 'r', encoding='utf-8') as f:
lines = f.readlines()

for line in lines:
if line.lstrip().startswith("version="):
# get rid of quotes around the version
line2 = line.replace('"', '')
# get rid of the trailing comma
line2 = line2.replace(',', '')
# split on =
words = line2.split("=")
# Note: This format is for github actions
print(f'::set-output name=version::{words[1].strip()}')