Skip to content

Commit

Permalink
Merge branch 'release/0.3.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
ControlNet committed Apr 1, 2024
2 parents bd592b0 + 5cff601 commit a99bffa
Show file tree
Hide file tree
Showing 20 changed files with 941 additions and 32 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/release-lib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Release lib

on:
workflow_call:
secrets:
PYPI_API_TOKEN:
required: true

jobs:

source:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Modify the setup files
run: |
rm -rf src/tensorneko_util
rm -rf src/tensorneko
rm -rf test
rm -rf .github
rm requirements.txt requirements_util.txt requirements_test.txt pypi.sh init.py .gitignore
rm setup.py
rm setup_util.py
mv pyproject_lib.toml pyproject.toml
new_version=$(cat version.txt) && sed -i "/^\[package\]$/,/^\[/ s/^version = \".*\"/version = \"$new_version\"/" Cargo.toml
rm version.txt
- uses: PyO3/maturin-action@v1
with:
command: sdist
args: -o dist
rust-toolchain: nightly
- name: Upload dist
uses: actions/upload-artifact@v2
with:
name: tensorneko-lib
path: dist

linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64, armv7, s390x, ppc64le]
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: Modify the setup files
run: |
rm -rf src/tensorneko_util
rm -rf src/tensorneko
rm setup.py
rm setup_util.py
mv pyproject_lib.toml pyproject.toml
new_version=$(cat version.txt) && sed -i "/^\[package\]$/,/^\[/ s/^version = \".*\"/version = \"$new_version\"/" Cargo.toml
- uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
rust-toolchain: nightly
target: ${{ matrix.target }}
args: --release -o dist -i 3.7 3.8 3.9 3.10 3.11 pypy3.8 pypy3.9
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: tensorneko-lib
path: dist

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Modify the setup files
run: |
Remove-Item src/tensorneko_util -Recurse -Force
Remove-Item src/tensorneko -Recurse -Force
Remove-Item setup.py -Force
Remove-Item setup_util.py -Force
Move-Item pyproject_lib.toml pyproject.toml
$new_version = Get-Content version.txt -Raw
$in_package_section = $false
(Get-Content Cargo.toml -Raw) -split "`r`n" | ForEach-Object {
if ($_ -match '^\[package\]$') {
$in_package_section = $true
}
if ($_ -match '^\[.*\]$' -and $_ -notmatch '^\[package\]$') {
$in_package_section = $false
}
if ($in_package_section -and $_ -match '^version = "') {
$_ -replace 'version = "[0-9]*\.[0-9]*\.[0-9]*"', "version = `"$new_version`""
} else {
$_
}
} | Set-Content Cargo.toml
shell: powershell

- uses: PyO3/maturin-action@v1
with:
command: build
target: x64
args: --release -o dist -i 3.7 3.8 3.9 3.10 3.11
rust-toolchain: nightly
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: tensorneko-lib
path: dist

macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Modify the setup files
run: |
rm -rf src/tensorneko_util
rm -rf src/tensorneko
rm setup.py
rm setup_util.py
mv pyproject_lib.toml pyproject.toml
new_version=$(cat version.txt) && sed -i '' "/^\[package\]$/,/^\[/ s/^version = \".*\"/version = \"$new_version\"/" Cargo.toml
- uses: PyO3/maturin-action@v1
with:
command: build
args: --release -o dist --sdist -i 3.7 3.8 3.9 3.10 3.11 pypy3.8 pypy3.9
target: universal2-apple-darwin
rust-toolchain: nightly
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: tensorneko-lib
path: dist

release:
name: Release
runs-on: ubuntu-latest
needs: [ macos, windows, linux, source ]
steps:
- uses: actions/download-artifact@v2
with:
name: tensorneko-lib
- name: Publish to PyPI
uses: messense/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
125 changes: 106 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ jobs:
runs-on: ubuntu-20.04
outputs:
local-version: ${{ steps.get-local-version.outputs.version }}
remote-version: ${{ steps.get-remote-version.outputs.version }}
remote-version-tensorneko: ${{ steps.get-remote-version-tensorneko.outputs.tensorneko-version }}
remote-version-tensorneko-util: ${{ steps.get-remote-version-tensorneko-util.outputs.tensorneko-util-version }}
remote-version-tensorneko-lib: ${{ steps.get-remote-version-tensorneko-lib.outputs.tensorneko-lib-version }}
steps:
- uses: actions/checkout@v2
- name: Get Local Version
id: get-local-version
run: echo "version=$(cat version.txt)" >> $GITHUB_OUTPUT
- name: Get Remote Version
id: get-remote-version
- name: Get Remote Version Tensorneko
id: get-remote-version-tensorneko
run: echo "version=$(curl -s https://pypi.org/pypi/tensorneko/json | jq -r '.info.version')" >> $GITHUB_OUTPUT
- name: Get Remote Version Tensorneko Util
id: get-remote-version-tensorneko-util
run: echo "version=$(curl -s https://pypi.org/pypi/tensorneko_util/json | jq -r '.info.version')" >> $GITHUB_OUTPUT
- name: Get Remote Version Tensorneko Lib
id: get-remote-version-tensorneko-lib
run: echo "version=$(curl -s https://pypi.org/pypi/tensorneko_lib/json | jq -r '.info.version')" >> $GITHUB_OUTPUT

build-web:
name: Build Web
Expand Down Expand Up @@ -98,10 +106,50 @@ jobs:
- name: Run Test
run: python -m unittest discover test

release:
name: Release
release-tensorneko:
name: Release Tensorneko
needs: [build-web, unittest, check-version]
if: needs.check-version.outputs.local-version != needs.check-version.outputs.remote-version-tensorneko
runs-on: ubuntu-20.04

strategy:
matrix:
python-version: [3.9]

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install wheel
python init.py
- name: Build package for tensorneko
run: python setup.py sdist bdist_wheel

- name: Save to artifact
uses: actions/upload-artifact@v2
with:
name: tensorneko
path: dist/

- name: Release tensorneko to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

release-tensorneko-util:
name: Release Tensorneko Util
needs: [build-web, unittest, check-version]
if: needs.check-version.outputs.local-version != needs.check-version.outputs.remote-version
if: needs.check-version.outputs.local-version != needs.check-version.outputs.remote-version-tensorneko-util
runs-on: ubuntu-20.04

strategy:
Expand Down Expand Up @@ -139,34 +187,73 @@ jobs:
- name: Build package for tensorneko_util
run: python setup_util.py sdist bdist_wheel

- name: Save to artifact
uses: actions/upload-artifact@v2
with:
name: tensorneko-util
path: dist/

- name: Release tensorneko_util to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_UTIL_API_TOKEN }}

- name: Clean build for tensorneko_util
run: |
rm -rf dist/
rm -rf build/
rm -rf src/tensorneko_util.egg-info/
release-tensorneko-lib:
name: Release Tensorneko Lib
needs: [check-version]
if: needs.check-version.outputs.local-version != needs.check-version.outputs.remote-version-tensorneko-lib
uses: ./.github/workflows/release-lib.yml
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_LIB_API_TOKEN }}

- name: Build package for tensorneko
run: python setup.py sdist bdist_wheel
github-release:
name: Release
needs: [release-tensorneko, release-tensorneko-util, release-tensorneko-lib]
runs-on: ubuntu-20.04

- name: Release tensorneko to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
strategy:
matrix:
python-version: [3.9]

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Get the version
run: |
VER=$(cat version.txt)
echo "VERSION=$VER" >> $GITHUB_ENV
- name: Rebuild tensorneko_util
run: python setup_util.py sdist bdist_wheel
- name: Download artifacts tensorneko
uses: actions/download-artifact@v2
with:
name: tensorneko
path: dist_tensorneko/

- name: Download artifacts tensorneko-util
uses: actions/download-artifact@v2
with:
name: tensorneko-util
path: dist_tensorneko_util/

- name: Download artifacts tensorneko-lib
uses: actions/download-artifact@v2
with:
name: tensorneko-lib
path: dist_tensorneko_lib/

- name: Merge the artifacts
run: |
mkdir dist
cp -r dist_tensorneko/* dist/
cp -r dist_tensorneko_util/* dist/
cp -r dist_tensorneko_lib/* dist/
- name: Release to GitHub Release
uses: marvinpinto/action-automatic-releases@latest
Expand Down
Loading

0 comments on commit a99bffa

Please sign in to comment.