Skip to content

Commit 08e6583

Browse files
committed
Refactor GitHub workflows and Makefile for version release.
- 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
1 parent b0edbca commit 08e6583

8 files changed

Lines changed: 45 additions & 144 deletions

File tree

‎.github/release-drafter.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ version-resolver:
2626
- 'patch'
2727
default: patch
2828
template: |
29-
## Changes
29+
## What's Changed
3030
3131
$CHANGES

‎.github/workflows/prelease.yaml‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎.github/workflows/publish.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
release:
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
VERSION: ${{ github.ref_name }}
17+
18+
steps:
19+
- run: make publish-package
20+
- run: make publish-image

‎.github/workflows/release-latest.yaml‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎.github/workflows/release-version.yaml‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎.github/workflows/release.yaml‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,19 @@ name: Release
22

33
on:
44
push:
5-
# Release on tags
6-
tags:
7-
- 'v*.*.*'
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
10+
permissions:
11+
contents: write
812

9-
# Ignore pre-release tags
10-
tags-ignore:
11-
- 'v*.*.*-*'
12-
1313
jobs:
1414
release:
15-
permissions:
16-
contents: write
17-
pull-requests: write
1815
runs-on: ubuntu-latest
1916

20-
env:
21-
VERSION: ${{ github.ref_name }}
22-
2317
steps:
24-
- run: make publish-package
25-
- run: make publish-image
2618
- uses: release-drafter/release-drafter@v5
2719
with:
2820
version: ${{ github.ref_name }}

‎Makefile‎

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -52,57 +52,6 @@ build:
5252
build-image:
5353
docker compose build
5454

55-
release-major:
56-
$(eval VERSION=$(shell echo "$(LATEST_TAG)" | awk -F'.' '{printf "%d.0.0", $$1 + 1}'))
57-
ifdef CI
58-
git config --global user.email "actions@github.com"
59-
git config --global user.name "GitHub Actions"
60-
endif
61-
sed -i '' "s/__version__ = '.*'/__version__ = '$(VERSION)'/g" transcribe_me/__init__.py
62-
git add transcribe_me/__init__.py
63-
git commit -m "chore: Bump version to $(VERSION)"
64-
git tag -a "v$(VERSION)"
65-
git push origin main
66-
git push --tags
67-
git branch --force -D release/$(VERSION)
68-
git checkout -b release/$(VERSION)
69-
git push --set-upstream origin release/$(VERSION)
70-
71-
release-minor:
72-
$(eval VERSION=$(shell echo "$(LATEST_TAG)" | awk -F'.' '{printf "%d.%d.0", $$1, $$2 + 1}'))
73-
ifdef CI
74-
git config --global user.email "actions@github.com"
75-
git config --global user.name "GitHub Actions"
76-
endif
77-
sed -i '' "s/__version__ = '.*'/__version__ = '$(VERSION)'/g" transcribe_me/__init__.py
78-
git add transcribe_me/__init__.py
79-
git commit -m "chore: Bump version to $(VERSION)"
80-
git tag -a "v$(VERSION)"
81-
git push origin main
82-
git push --tags
83-
git branch --force -D release/$(VERSION)
84-
git checkout -b release/$(VERSION)
85-
git push --set-upstream origin release/$(VERSION)
86-
87-
release-patch:
88-
$(eval VERSION=$(shell echo "$(LATEST_TAG)" | awk -F'.' '{printf "%d.%d.%d", $$1, $$2, $$3 + 1}'))
89-
ifdef CI
90-
git config --global user.email "actions@github.com"
91-
git config --global user.name "GitHub Actions"
92-
endif
93-
sed -i '' "s/__version__ = '.*'/__version__ = '$(VERSION)'/g" transcribe_me/__init__.py
94-
git add transcribe_me/__init__.py
95-
git commit -m "chore: Bump version to $(VERSION)"
96-
git tag -a "v$(VERSION)"
97-
git push origin main
98-
git push --tags
99-
git branch --force -D release/$(VERSION)
100-
git checkout -b release/$(VERSION)
101-
git push --set-upstream origin release/$(VERSION)
102-
103-
gh-publish-image:
104-
gh workflow view prerelease.yaml --web
105-
10655
publish-package:
10756
rm -rdf dist
10857
$(MAKE) build
@@ -122,4 +71,13 @@ transcribe-archive: install
12271
$(VENV) python -m transcribe_me.main archive
12372

12473
transcribe-install: install
125-
$(VENV) python -m transcribe_me.main install
74+
$(VENV) python -m transcribe_me.main install
75+
76+
release-version:
77+
ifdef CI
78+
git config --global user.email "actions@github.com"
79+
git config --global user.name "GitHub Actions"
80+
endif
81+
git tag -a "v$(VERSION)"
82+
git push origin main
83+
git push --tags

‎transcribe_me/__init__.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
__version__ = '0.5.0'
1+
import os
2+
3+
__version__ = os.environ.get("VERSION")
4+
5+
if __version__ is None:
6+
print("Error: VERSION environment variable is not set.")
7+
exit(1)

0 commit comments

Comments
 (0)