-
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.
Adding in workflows for curating binaries for mac,linux,and windows. …
…Adding code toe check shell and run on windows systems
- Loading branch information
1 parent
9d4dedb
commit a2b07cf
Showing
4 changed files
with
307 additions
and
3 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,59 @@ | ||
# Note - This is not my original work. | ||
# Credit where credit is due, checkout the original works here: https://github.com/portapack-mayhem/mayhem-firmware/blob/next/.github/workflows/changelog.py | ||
import os | ||
import sys | ||
|
||
import requests | ||
from datetime import datetime, timedelta, timezone | ||
|
||
# Set up your personal access token and the repository details | ||
token = os.environ.get('GH_TOKEN') | ||
repo_owner = "bitlytwiser" | ||
repo_name = "apprunner" | ||
|
||
def print_stable_changelog(): | ||
url = f"compare/{changelog_from_last_commit}...next" | ||
commits = handle_get_request(url) | ||
for commit in commits["commits"]: | ||
# Print the commit details | ||
print(format_output(commit)) | ||
|
||
def changelog_from_last_commit(): | ||
headers = {} if token == None else {"Authorization": f"Bearer {token}"} | ||
url_base = f"https://api.github.com/repos/{repo_owner}/{repo_name}/commits/master" | ||
response = requests.get(url_base, headers=headers) | ||
|
||
if response.status_code == 200: | ||
data = response.json() | ||
return data["sha"] | ||
else: | ||
print(f"Request failed with status code: {response.status_code}") | ||
return None | ||
|
||
def curate_changelog_from_dates(): | ||
# Calculate the date and time 24 hours ago | ||
since_time = (datetime.now(timezone.utc) - timedelta(hours=24)).isoformat() # Check that this is UTC | ||
url = "commits" | ||
commits = handle_get_request(url, since_time) | ||
for commit in commits: | ||
print(format_output(commit)) | ||
|
||
def handle_get_request(path, offset=None): | ||
headers = {} if token == None else {"Authorization": f"Bearer {token}"} | ||
params = {"since": offset} | ||
url_base = f"https://api.github.com/repos/{repo_owner}/{repo_name}/" | ||
response = requests.get(url_base + path, headers=headers, params=params) | ||
|
||
if response.status_code == 200: | ||
return response.json() | ||
else: | ||
print(f"Request failed with status code: {response.status_code}") | ||
return None | ||
|
||
|
||
def format_output(commit): | ||
message_lines = commit["commit"]["message"].split("\n") | ||
author = commit["author"]["login"] if commit["author"] and "login" in commit["author"] else commit["commit"]["author"]["name"] | ||
return '- ' + commit["sha"][:8] + ' - @' + author + ': ' + message_lines[0] | ||
|
||
print_stable_changelog |
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,123 @@ | ||
name: Binary Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Single checkout, with submodules | ||
- name: Checkout | ||
uses: actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
|
||
- name: Print latest commit | ||
run: echo ${{ github.sha }} | ||
|
||
- name: "Install Zig" | ||
run: "sudo snap install zig --classic --beta" | ||
|
||
# Date for versioning | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
|
||
- name: Get version date | ||
id: version_date | ||
run: echo "date=n_$(date +'%y%m%d')" >> $GITHUB_OUTPUT | ||
|
||
# Linux binary creation | ||
- name: Package and create binary for Linux | ||
run: | | ||
mkdir -p apprunner_linux | ||
zig build -p apprunner_linux/ --release=fast -Dtarget=x86_64-linux | ||
zip -r apprunner_linux.zip apprunner_linux | ||
# Windows binary creation | ||
- name: Package and create binary for Windows | ||
run: | | ||
mkdir -p apprunner_windows | ||
zig build -p apprunner_windows/--release=fast -Dtarget=x86_64-windows | ||
zip -r apprunner_windows.zip apprunner_windows | ||
# MacOS Binary Creation | ||
- name: Package and create binary for MacOS | ||
run: | | ||
mkdir -p apprunner_windows | ||
zig build -p apprunner_windows/--release=fast -Dtarget=x86_64-macos | ||
zip -r apprunner_macos.zip apprunner_macos | ||
# Changelog generation | ||
- name: Create changelog | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
{ | ||
echo 'content<<EOF' | ||
python3 .github/workflows/changelog.py | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
id: changelog | ||
|
||
# Release creation | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: binary-tag-${{ steps.date.outputs.date }}-${{ github.sha }} | ||
release_name: Binary Release - ${{ steps.date.outputs.date }} | ||
body: | | ||
**Binary release - ${{ steps.date.outputs.date }}** | ||
This build is the latest code changes for apprunner. | ||
## Release notes | ||
### Revision (${{ steps.version_date.outputs.date }}): | ||
${{ steps.changelog.outputs.content }} | ||
draft: false | ||
prerelease: true | ||
|
||
# Upload binaries (Windows) | ||
- name: Upload Apprunner Binary Windows | ||
id: upload-apprunner-binary-windows | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./apprunner.zip | ||
asset_name: apprunner${{ steps.version_date.outputs.date }}_binary_windows.zip | ||
asset_content_type: application/zip | ||
|
||
# Upload binaries (Linux) | ||
- name: Upload Apprunner Binary Linux | ||
id: upload-apprunner-binary-linux | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./apprunner.zip | ||
asset_name: apprunner${{ steps.version_date.outputs.date }}_binary_linux.zip | ||
asset_content_type: application/zip | ||
|
||
# Upload binaries (MacOS) | ||
- name: Upload Apprunner Binary MacOS | ||
id: upload-apprunner-binary-mac | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./apprunner.zip | ||
asset_name: apprunner${{ steps.version_date.outputs.date }}_binary_macos.zip | ||
asset_content_type: application/zip |
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
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