Skip to content

Commit

Permalink
Refactor GitHub workflows and Makefile for version release.
Browse files Browse the repository at this point in the history
- Remove unnecessary targets from Makefile
- Add new `release-version` target for releasing versions
- Improve version retrieval in `__init__.py`
- Delete unused GitHub workflow files
- Add new GitHub workflow for publishing with tag triggers
- Simplify and update permissions in release workflow
- Update release-drafter template for clarity
  • Loading branch information
johnnyhuy committed Apr 20, 2024
1 parent b0edbca commit 08e6583
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ version-resolver:
- 'patch'
default: patch
template: |
## Changes
## What's Changed
$CHANGES
27 changes: 0 additions & 27 deletions .github/workflows/prelease.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish

on:
push:
tags:
- 'v*.*.*'

jobs:
release:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest

env:
VERSION: ${{ github.ref_name }}

steps:
- run: make publish-package
- run: make publish-image
21 changes: 0 additions & 21 deletions .github/workflows/release-latest.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/release-version.yaml

This file was deleted.

22 changes: 7 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@ name: Release

on:
push:
# Release on tags
tags:
- 'v*.*.*'
branches:
- main
pull_request:
types: [opened, reopened, synchronize]

permissions:
contents: write

# Ignore pre-release tags
tags-ignore:
- 'v*.*.*-*'

jobs:
release:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest

env:
VERSION: ${{ github.ref_name }}

steps:
- run: make publish-package
- run: make publish-image
- uses: release-drafter/release-drafter@v5
with:
version: ${{ github.ref_name }}
Expand Down
62 changes: 10 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,57 +52,6 @@ build:
build-image:
docker compose build

release-major:
$(eval VERSION=$(shell echo "$(LATEST_TAG)" | awk -F'.' '{printf "%d.0.0", $$1 + 1}'))
ifdef CI
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
endif
sed -i '' "s/__version__ = '.*'/__version__ = '$(VERSION)'/g" transcribe_me/__init__.py
git add transcribe_me/__init__.py
git commit -m "chore: Bump version to $(VERSION)"
git tag -a "v$(VERSION)"
git push origin main
git push --tags
git branch --force -D release/$(VERSION)
git checkout -b release/$(VERSION)
git push --set-upstream origin release/$(VERSION)

release-minor:
$(eval VERSION=$(shell echo "$(LATEST_TAG)" | awk -F'.' '{printf "%d.%d.0", $$1, $$2 + 1}'))
ifdef CI
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
endif
sed -i '' "s/__version__ = '.*'/__version__ = '$(VERSION)'/g" transcribe_me/__init__.py
git add transcribe_me/__init__.py
git commit -m "chore: Bump version to $(VERSION)"
git tag -a "v$(VERSION)"
git push origin main
git push --tags
git branch --force -D release/$(VERSION)
git checkout -b release/$(VERSION)
git push --set-upstream origin release/$(VERSION)

release-patch:
$(eval VERSION=$(shell echo "$(LATEST_TAG)" | awk -F'.' '{printf "%d.%d.%d", $$1, $$2, $$3 + 1}'))
ifdef CI
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
endif
sed -i '' "s/__version__ = '.*'/__version__ = '$(VERSION)'/g" transcribe_me/__init__.py
git add transcribe_me/__init__.py
git commit -m "chore: Bump version to $(VERSION)"
git tag -a "v$(VERSION)"
git push origin main
git push --tags
git branch --force -D release/$(VERSION)
git checkout -b release/$(VERSION)
git push --set-upstream origin release/$(VERSION)

gh-publish-image:
gh workflow view prerelease.yaml --web

publish-package:
rm -rdf dist
$(MAKE) build
Expand All @@ -122,4 +71,13 @@ transcribe-archive: install
$(VENV) python -m transcribe_me.main archive

transcribe-install: install
$(VENV) python -m transcribe_me.main install
$(VENV) python -m transcribe_me.main install

release-version:
ifdef CI
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
endif
git tag -a "v$(VERSION)"
git push origin main
git push --tags
8 changes: 7 additions & 1 deletion transcribe_me/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
__version__ = '0.5.0'
import os

__version__ = os.environ.get("VERSION")

if __version__ is None:
print("Error: VERSION environment variable is not set.")
exit(1)

0 comments on commit 08e6583

Please sign in to comment.