Skip to content

Commit

Permalink
MERGE BACK: main to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mahiki committed Jul 22, 2024
2 parents 3bacf87 + 1de8688 commit e930f33
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 193 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/GHA.actions-handy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,27 @@ jobs:
just-macos-things:
runs-on: macos-latest
steps:
- name: some basic items
run: |
printf "github.event_name: %s\n" '${{ github.event_name }}'
printf "runner.os: %s\n" '${{ runner.os }}'
printf "github.ref (branch): %s\n" '${{ github.ref }}'
printf "github.repository: %s\n" '${{ github.repository }}'
printf "github workspace: %s\n" '${{ github.workspace }}'
printf "github branch/tag name: %s\n" '${{ github.ref_name }}'
printf "github branch/tag name from env var: %s\n" "$GITHUB_REF_NAME"
- name: Get latest tag
id: get_tag
run: echo ::set-output name=tag::$(git describe --tags --abbrev=0)

- name: Get latest tag
id: get_tag
run: |
"tag=$(git describe --tags --abbrev=0)"
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: some basic items
run: |
printf "github.event_name: %s\n" '${{ github.event_name }}'
printf "runner.os: %s\n" '${{ runner.os }}'
printf "github.ref (branch): %s\n" '${{ github.ref }}'
printf "github.repository: %s\n" '${{ github.repository }}'
printf "github workspace: %s\n" '${{ github.workspace }}'
printf "github branch/tag name: %s\n" '${{ github.ref_name }}'
printf "github branch/tag name from env var: %s\n" "$GITHUB_REF_NAME"
printf "latest tag name: %s\n" "${{ steps.get_tag.outputs.tag }}"

ubuntu-town:
runs-on: ubuntu-latest
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
name: Merge Release Branch and Tag

env:
ACTIONS_STEP_DEBUG: true
RELEASE_BRANCH: ${{ github.event.workflow_run.head_branch }}

on:
workflow_run:
workflows: [Test desertislandutils]
types: [completed]
branches:
- 'release/**'

env:
RELEASE_BRANCH: ${{ github.event.workflow_run.head_branch }}

jobs:
print-branch-vars:
merge-and-tag:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Show workspace contexts
run: |
echo "head branch of trigger run: ${{ github.event.workflow_run.head_branch }}"
echo "shell RELEASE_BRANCH: $RELEASE_BRANCH"
merge-and-tag:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Checkout the whole repo'
uses: actions/checkout@v3
- name: Checkout the whole repo
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -43,6 +41,12 @@ jobs:
git branch --list
git log --graph -n10 --pretty=format:'%h %as %cn %x09%s %d'
# - name: Merge back to dev
# run: |
# git checkout dev
# git merge --no-ff main
# git push origin dev

- name: Merge the latest release commit
run: |
echo "release_tag_name: $release_tag_name"
Expand All @@ -51,22 +55,18 @@ jobs:
# required to initialise branch visibility
git checkout "$RELEASE_BRANCH"
git checkout main
git branch --list
git merge --no-ff "$RELEASE_BRANCH"
git push origin main
git tag --annotate "$release_tag_name" -m "release $release_tag_name"
git push origin "$release_tag_name"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"
git log --graph --all -n10 --pretty=format:'%h %as %cn %x09%s %d'
- name: Merge back to dev
- name:
run: |
git checkout dev
git merge --no-ff main
git push origin dev
echo "RELEASE AND DEV MERGED"
echo "YOU CAN DELETE RELEASE BRANCH: $RELEASE_BRANCH"
echo "RELEASE AND DEV MERGED"
on-failure:
runs-on: ubuntu-latest
Expand Down
50 changes: 35 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
name: Release desertislandutils
# create a release from the latest tag on MAIN or something

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
ACTIONS_STEP_DEBUG: true

on:
workflow_run:
workflows: [Merge Release Branch and Tag]
types: [completed]
branches:
- 'main'

jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'

- run: python --version
- run: |
pipx install --python $(which python) poetry
poetry install
poetry show --latest
- run: |
- name: Install Poetry
run: |
python --version
pipx install --python $(which python) poetry
poetry --version
poetry install
poetry show --latest
- name: Get Gatest Tag
id: get_tag
run: |
git branch --list
git log --oneline --tags -n10 --pretty=format:'%h %as %cn %x09%s %d'
echo
echo "current tag is ${{ github.ref_name }}"
echo "current ref is ${{ github.ref_name }}"
latest_tag="$(git describe --tags --abbrev=0)"
echo "latest tag: ${latest_tag}"
echo latest_tag="${latest_tag}" >> $GITHUB_OUTPUT
- name: Build poetry distribution
run: poetry build
- name: Build Poetry Distribution from Latest Tag
run: |
git checkout ${{ steps.get_tag.outputs.latest_tag }}"
poetry build
- name: Create release from tag
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
generateReleaseNotes: true
tag: ${{ steps.get_tag.outputs.latest_tag }}
50 changes: 36 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
name: Test desertislandutils

env:
ACTIONS_STEP_DEBUG: true

on:
push:
branches:
- 'dev'
- 'main'
- '**'
paths-ignore:
- '**.md'
pull_request:
branches:
- '**'
paths-ignore:
- '**.md'

# NOTE: workflow_dispatch only work on main
workflow_dispatch:
inputs:
Expand All @@ -34,22 +36,42 @@ jobs:
poetry-run-tests:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'

- run: python --version
- run: pipx install --python $(which python) poetry
- run: poetry install
- run: poetry show --latest
- run: poetry run pytest --disable-warnings --verbose
- run: |
echo "REMINDER: Warnings are disabled"
- name: Install Poetry
run: |
python --version
pipx install --python $(which python) poetry
poetry --version
poetry install
poetry show --latest
- name: Poetry Run Pytest
run: |
poetry run pytest --disable-warnings --verbose
echo "WARNING: Pytest Warnings are disabled"
- name: Get Latest Tag
id: get_tag
run: |
latest_tag="$(git ls-remote origin 'refs/tags/v*[0-9]' | awk -F'refs/tags/' '{print $2}' | sort -V | tail -1)"
echo latest_tag="${latest_tag}" >> $GITHUB_OUTPUT
- name: Get desertislandutils Version
id: app_version
run: |
poetry_app_version="$(poetry version --short)"
echo poetry_app_version="v${poetry_app_version}" >> $GITHUB_OUTPUT
- name: Print some workflow contexts
- name: REFERENCE - Variables and Workflow Contexts
run: |
echo "workflow: ${{ github.workflow }}"
echo "job_id: ${{ github.job }}"
echo "job status: ${{ job.status }}"
echo "commit tag name: ${{ github.ref_name }}"
echo "commit ref name: ${{ github.ref_name }}"
echo "branch name: ${{ github.ref }}"
echo "latest tag: ${{ steps.get_tag.outputs.latest_tag }}"
echo "poetry app version: ${{ steps.app_version.outputs.poetry_app_version }}"
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# desertislandutils
Refactoring my convenience utility bash scripts into python for learning and profit.
Refactoring my convenience utility bash scripts into python for learning and profit. Deployed for MacOS via homebrew, its really far better than shell scripting, yuck!

* build: poetry
* deploy: poetry -> pypi -> homebew
* github CI actions
## INSTALL
brew install mahiki/tap/desertislandutils

## SCRIPTS
## THE UTILS
### toobigdatadoc
I like to keep text files in one directory system, with supporting data files and binary documents in parallel directories from the home folder: `toobig`, `toodata`, `toodoc`. For example, its easy to exclude the whole `toobig` directory structure from backups, since there is nothing but huge files here.

Expand Down Expand Up @@ -53,4 +52,28 @@ wn --help
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
```

----------
## DEVELOPMENT
>Trying to automate the merge tag homebrew tap repo upgrade thing. Its not going great.
* build: poetry
* deploy: poetry -> pypi -> homebrew
* github CI actions

### JUSTFILE
>Best documentation is in the Just taskrunner `justfile`.
```sh
just info

just wn --help

# also direct into poetry environment
poetry shell
(desertislandutils)> wn --help
```

### Testing
just test
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.7'
__version__ = '0.3.8'
46 changes: 46 additions & 0 deletions base.justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Default justfile for import

# just --list
[private]
ac3e01d:
@just --justfile base.justfile --list --unsorted --list-heading $'Default Justfile for Imports\n'

# color code definitions for use in any justfile
[private]
colordefs:
@echo
@echo "{{BCY}}Terminal color code definitions included for use in any justfile{{NC}}"
@echo ' For example, {{{{BCY}} gives:'
@echo " {{BCY}}Bright Cyan{{NC}}"
@echo

# show the color codes
colortest:
@echo " {{NC}}NC{{NC}}"
@echo " {{BK}}BK{{NC}} {{BL}}BL{{NC}}"
@echo " {{BBK}}BBK{{NC}} {{BBL}}BBL{{NC}}"
@echo " {{RD}}RD{{NC}} {{MG}}MG{{NC}}"
@echo " {{BRD}}BRD{{NC}} {{BMG}}BMG{{NC}}"
@echo " {{GR}}GR{{NC}} {{CY}}CY{{NC}}"
@echo " {{BGR}}BGR{{NC}} {{BCY}}BCY{{NC}}"
@echo " {{YW}}YW{{NC}} {{WT}}WT{{NC}}"
@echo " {{BYW}}BYW{{NC}} {{BWT}}BWT{{NC}}"

# color decorations
BK := '\033[0;30m' # Black
BBK := '\033[1;30m' # Bright Gray
RD := '\033[0;31m' # Red
BRD := '\033[1;31m' # Bright Red
GR := '\033[0;32m' # Green
BGR := '\033[1;32m' # Bright Green
YW := '\033[0;33m' # Yellow
BYW := '\033[1;33m' # Bright Yellow
BL := '\033[0;34m' # Blue
BBL := '\033[1;34m' # Light Blue
MG := '\033[0;35m' # Magenta
BMG := '\033[1;35m' # Light Purple
CY := '\033[0;36m' # Cyan
BCY := '\033[1;36m' # Light Cyan
WT := '\033[0;37m' # White
BWT := '\033[1;37m' # Light White
NC := '\033[0m'
Loading

0 comments on commit e930f33

Please sign in to comment.