Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release workflow to github, pypi, and docker hub #10

Merged
merged 62 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
0fa190c
initial commit
grqz Aug 31, 2024
5e5cc4f
modified: .github/workflows/release.yml
grqz Aug 31, 2024
cb04b51
modified: .github/workflows/release.yml
grqz Aug 31, 2024
fc9ba16
fix path
grqz Sep 1, 2024
a24f95b
debug
grqz Sep 1, 2024
db39bb4
fix
grqz Sep 1, 2024
5bb8209
fix
grqz Sep 1, 2024
ae1e32a
debug
grqz Sep 1, 2024
725a869
try: pypi
grqz Sep 1, 2024
43d1913
modified project name for testing
grqz Sep 1, 2024
80232a9
test: docker
grqz Sep 1, 2024
efb96bf
change docker hub release condition
grqz Sep 1, 2024
082fce8
- add docker meta tags
grqz Sep 1, 2024
33c17c1
- change taggerdate to creatordate
grqz Sep 1, 2024
49dc2a6
Rel 0.2.2
grqz Sep 1, 2024
646e363
rel 0.2.3
grqz Sep 1, 2024
1053040
rel 0.2.4
grqz Sep 1, 2024
7457288
rel 0.2.5
grqz Sep 1, 2024
ec838ca
Release 0.2.6
grqz Sep 1, 2024
5c981a2
Release 0.2.7
grqz Sep 1, 2024
b51c074
REL0.2.8: [gh] fix CHANGELOG
grqz Sep 1, 2024
b243e52
REL 0.2.9: [gh] fix changelog path
grqz Sep 1, 2024
1fb04c2
- [github] fix git log
grqz Sep 1, 2024
33a3ad5
[pypi] test: add yt-dlp-get-pot as a dep
grqz Sep 1, 2024
a51080a
REL 0.2.11
grqz Sep 1, 2024
f4f0d30
REL 0.2.12
grqz Sep 1, 2024
d461c28
rel 0.2.13: debug
grqz Sep 1, 2024
c058b9a
REL 0.2.14
grqz Sep 1, 2024
24b1a15
REL 0.2.15
grqz Sep 1, 2024
f19300f
REL 0.2.16
grqz Sep 1, 2024
acd2121
REL 0.2.17
grqz Sep 2, 2024
6477895
REL 0.2.18 increment version
grqz Sep 2, 2024
2cd1139
Merge pull request #1 from grqz/grqz-inc-ver
grqz Sep 2, 2024
7a3e2c3
[github] change changelog format
grqz Sep 2, 2024
2793ff5
[REL0.2.19] Increment version
grqz Sep 2, 2024
e026208
[merge commistmsg] Merge pull request #2 from grqz/grqz-inc-ver
grqz Sep 2, 2024
e3ee0e0
REL 0.2.20
grqz Sep 2, 2024
c0e05a0
rel 0.2.21
grqz Sep 2, 2024
3f1fe3e
increment version
grqz Sep 2, 2024
1ca65ac
Merge pull request #3 from grqz/grqz-patch-1
grqz Sep 2, 2024
ea896bc
[gh] fix time range for changelog
grqz Sep 2, 2024
e1aca22
0.2.23 Update pyproject.toml
grqz Sep 2, 2024
83e3278
Merge pull request #4 from grqz/grqz-patch-0223
grqz Sep 2, 2024
892c53e
version 0.2.24 Update pyproject.toml
grqz Sep 2, 2024
71d9533
Merge pull request #5 from grqz/grqz-0224
grqz Sep 2, 2024
fba1f6d
test pr
grqz Sep 2, 2024
1ca849f
Merge pull request #6 from grqz/grqz-patch-tmp
grqz Sep 2, 2024
283ba9f
test the workflow triggered by a pr
grqz Sep 2, 2024
0696592
[gh] remove git tag prefix
grqz Sep 2, 2024
05992bd
- [docker] more tags
grqz Sep 2, 2024
bd30d3b
[gh] try to fix create release if condition
grqz Sep 2, 2024
dfb8814
REL 0.2.26
grqz Sep 2, 2024
58f97eb
REL 0.2.27
grqz Sep 2, 2024
fee5fc3
REL:0.2.27
grqz Sep 2, 2024
7b14ef5
Delete build.yml
grqz Sep 2, 2024
8fb1554
REL 0.2.28
grqz Sep 2, 2024
6a1c87c
try to allow overwriting github releases
grqz Sep 2, 2024
c1e7a63
[gh] fix condition
grqz Sep 2, 2024
210d11a
read from release notes
grqz Sep 2, 2024
81becb3
0.0.29: gh cleanup and final rel
grqz Sep 2, 2024
62aa290
Prepare to merge
grqz Sep 2, 2024
58eeae7
[PyPI] add `yt-dlp-plugins-get-pot` keyword
grqz Sep 3, 2024
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
26 changes: 0 additions & 26 deletions .github/workflows/build.yml

This file was deleted.

186 changes: 186 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: Create release
on:
workflow_dispatch:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
release:
name: Release to Github
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_variables.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.8"

- name: Install Hatch
run: pipx install hatch

- name: Set variables
id: set_variables
run: |
cp README.md plugin/
cd plugin/
metadata=$(hatch project metadata)
echo "::group::Variables"
cat << EOF | tee -a "$GITHUB_OUTPUT"
tag=$(git for-each-ref refs/tags --sort=-creatordate --format='%(refname:strip=2)' --count=1)
version=$(echo ${metadata} | jq -r .version)
project_name=$(echo ${metadata} | jq -r .name)
EOF
echo "::endgroup::"
- name: Bundle
if: github.event_name != 'pull_request' && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref
grqz marked this conversation as resolved.
Show resolved Hide resolved
# only release on default branch
id: bundle
env:
GH_TOKEN: ${{ github.token }}
tag: ${{ steps.set_variables.outputs.tag }}
version: ${{ steps.set_variables.outputs.version }}
project_name: ${{ steps.set_variables.outputs.project_name }}
shell: bash
run: |
cd plugin/
mkdir bundle/
cp -r yt_dlp_plugins bundle/
cd bundle/
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
zip -9 --recurse-paths "${project_name}" *
printf "## What's Changed\n\n" >> CHANGELOG.md
gh pr list --json author,number,title,mergedAt --state merged -R ${{ github.repository }} \
| jq -r --arg authortime "$(git log --format='%at' -n1 ${tag})" \
'.[]|select((.mergedAt|strptime("%Y-%m-%dT%H:%M:%SZ")|mktime)>($authortime|tonumber))| "* \(.title) by @\(.author.login) in #\(.number|tostring)"' \
>> CHANGELOG.md
printf "\n**Full Changelog**: ${{ github.server_url }}/${{ github.repository }}/compare/${tag}...${version}\n" >> CHANGELOG.md
r=$(cat CHANGELOG.md) # <--- Read release Notes
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "RELEASE_BODY=$r" | tee -a $GITHUB_OUTPUT # <--- Set environment variable

- name: Create Release on Github
if: github.event_name != 'pull_request' && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref
# only release on default branch
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ steps.set_variables.outputs.version }}
release_name: |
${{ steps.set_variables.outputs.project_name }} ${{ steps.set_variables.outputs.version }}
body: ${{ steps.bundle.outputs.RELEASE_BODY }}
file: plugin/bundle/${{ steps.set_variables.outputs.project_name }}.zip
asset_name: ${{ steps.set_variables.outputs.project_name }}.zip
overwrite: true

release_pypi:
name: Release to PyPI
if: github.event_name != 'pull_request' && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref
# only release on default branch
runs-on: ubuntu-latest
permissions:
id-token: write # mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build hatchling

- name: Build
run: |
cd plugin/
rm -rf dist/**
printf '%s\n\n' \
"Official repository: <${{ github.server_url }}/${{ github.repository }}>" > ./README.md.new
cat ../README.md >> ./README.md.new && mv -f ./README.md.new ./README.md
python -m build --no-isolation .

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
packages-dir: plugin/dist

release_docker:
name: Build Docker Image
needs: release
runs-on: ubuntu-latest
permissions:
packages: write
env:
repository: ${{ github.repository }} # like `brainicism/bgutil-ytdlp-pot-provider`
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
context: git
images: ${{ env.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
# mark as latest only if built on default branch of repository
type=raw,value=ci,enable={{is_default_branch}}
# mark as ci only if built on default branch of repository
type=raw,value=${{ needs.release.outputs.version }},enable={{is_default_branch}}
# add the new git tag only if built on default branch of repository
type=sha
type=ref,event=branch
type=ref,event=pr

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: server/
file: server/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
Brainicism marked this conversation as resolved.
Show resolved Hide resolved
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}

- name: Add official repository link to README.md
if: github.event_name != 'pull_request'
run: |
printf '%s\n\n' \
"Official repository: <${{ github.server_url }}/${{ github.repository }}>" > ./README.md.new
cat ./README.md >> ./README.md.new && mv -f ./README.md.new ./README.md

- name: Update repo description
if: github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.repository }}
short-description: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}
readme-filepath: README.md
6 changes: 6 additions & 0 deletions plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/**
README.md
CHANGELOG.md
*.pyc
*.pyo
__pycache__/
26 changes: 26 additions & 0 deletions plugin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "bgutil-ytdlp-pot-provider"
version = "0.2.1"
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.8"
keywords = ["yt-dlp", "yt-dlp-plugin", "yt-dlp-plugins-get-pot"]
authors = [
{ name = "Brainicism", email = "[email protected]" },
]
dependencies = [
"yt-dlp-get-pot>=0.0.2",
]

[tool.hatch.env.default]
installer = "uv"
path = ".venv"

[tool.hatch.build.targets.wheel]
packages = ["yt_dlp_plugins"]

[tool.hatch.metadata]
allow-direct-references = true