Skip to content

Commit

Permalink
Replace version (NewFuture#340)
Browse files Browse the repository at this point in the history
* replace version

* rm Travis

* update badge
  • Loading branch information
NewFuture committed Jul 28, 2022
1 parent 772cc51 commit ecca037
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 72 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install build
- run: sed -i -e "s#\${BUILD_SOURCEBRANCHNAME}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- name: Build package
run: python -m build --sdist --wheel --outdir dist/

- uses: actions/upload-artifact@v3
with:
name: pypi
path: dist/
retention-days: 7
retention-days: 5

pyinstaller:
strategy:
Expand All @@ -75,10 +75,10 @@ jobs:

# Prepare build version and cert
- name: Replace build version
run: sed -i${{ fromJSON('["",".temp"]')[matrix.os == 'macos'] }} -e "s#\${BUILD_SOURCEBRANCHNAME}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
- name: Copy cert on ubuntu
if: ${{ matrix.os == 'ubuntu' }}
if: runner.os == 'Linux'
run: cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem

- run: python ./run.py -h
Expand All @@ -94,14 +94,14 @@ jobs:
with:
name: ${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/
retention-days: 14
retention-days: 7

docker:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- run: sed -i -e "s#\${BUILD_SOURCEBRANCHNAME}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: docker/build-push-action@v3
with:
context: .
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v3
- run: sed -i -e "s#\${BUILD_SOURCEBRANCHNAME}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
Expand Down
56 changes: 54 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v3
- run: sed -i -e "s#\${BUILD_SOURCEBRANCHNAME}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
url: https://pypi.org/project/ddns/
steps:
- uses: actions/checkout@v3
- run: sed -i -e "s#\${BUILD_SOURCEBRANCHNAME}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py
- uses: actions/setup-python@v4
with:
python-version: "3.x"
Expand All @@ -66,3 +66,55 @@ jobs:
with:
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true

publish-binary:
strategy:
# fail-fast: false
matrix:
os: [windows, macos, ubuntu]
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 8
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: pip install pyinstaller

- name: Replace build version
run: sed -i.tmp -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" -e "s/\${BUILD_DATE}/$(date --iso-8601=seconds)/" run.py && rm run.py.tmp
shell: bash
- name: Copy cert on ubuntu
if: ${{ matrix.os == 'ubuntu' }}
run: cp /etc/ssl/certs/ca-certificates.crt cert.pem && export SSL_CERT_FILE=${PWD}/cert.pem

- run: pyinstaller --noconfirm --clean ./.build/ddns.spec
- run: ./dist/ddns || test -e config.json
- run: ./dist/ddns -h

- uses: softprops/action-gh-release@v1
with:
draft: true
generate_release_notes: false
files: dist/

github-release:
runs-on: ubuntu-latest
timeout-minutes: 5
environment:
name: publish
url: https://github.com/NewFuture/DDNS/releases
permissions:
contents: write
needs: [publish-docker, publish-pypi, publish-binary]
steps:
- uses: actions/checkout@v3
- run: sed -i -e "s#\${BUILD_VERSION}#${{ github.ref_name }}#" .release/README.md
- uses: softprops/action-gh-release@v1
with:
draft: false
generate_release_notes: true
files: |
.release/*.sh
.release/*.bat
20 changes: 10 additions & 10 deletions .release/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[![PyPI version](https://img.shields.io/badge/DDNS-${BUILD_SOURCEBRANCHNAME}-1abc9c.svg?style=social)](https://pypi.org/project/ddns/${BUILD_SOURCEBRANCHNAME}/) ![Deploy OK](https://img.shields.io/badge/release-success-brightgreen.svg?style=flat-square)
[![PyPI version](https://img.shields.io/badge/DDNS-${BUILD_VERSION}-1abc9c.svg?style=social)](https://pypi.org/project/ddns/${BUILD_VERSION}/) ![Deploy OK](https://img.shields.io/badge/release-success-brightgreen.svg?style=flat-square)

## 使用二进制文件 ![cross platform](https://img.shields.io/badge/platform-windows_%7C%20linux_%7C%20osx-success.svg?style=flat-square)

* Windows 下载 [ddns.exe](https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/ddns.exe)
* Ubuntu 下载 [ddns](https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/ddns)
* Mac OS X下载 [ddns-osx](https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/ddns-osx)
* Windows 下载 [ddns.exe](https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/ddns.exe)
* Ubuntu 下载 [ddns](https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/ddns)
* Mac OS X下载 [ddns-osx](https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/ddns-osx)

各平台下载/使用方式

* ### Windows
1. 下载 [`ddns.exe`](https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/ddns.exe) 运行
2. [可选] 定时任务 下载 [`create-task.bat`](https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/create-task.bat)**相同目录**,以管理员权限运行
1. 下载 [`ddns.exe`](https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/ddns.exe) 运行
2. [可选] 定时任务 下载 [`create-task.bat`](https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/create-task.bat)**相同目录**,以管理员权限运行
* ### Ubuntu
```bash
# 1. 下载ddns
curl https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/ddns -#SLo ddns && chmod +x ddns
curl https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/ddns -#SLo ddns && chmod +x ddns
# 2. [可选] 定时任务(当前目录):
curl -sSL https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/create-task.sh | bash
curl -sSL https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/create-task.sh | bash
```
* ### Mac OSX
```sh
# 命令行下载
curl https://github.com/NewFuture/DDNS/releases/download/${BUILD_SOURCEBRANCHNAME}/ddns-osx -#SLo ddns && chmod +x ddns
curl https://github.com/NewFuture/DDNS/releases/download/${BUILD_VERSION}/ddns-osx -#SLo ddns && chmod +x ddns
```

## 使用PIP 安装 ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ddns.svg?style=flat-square) ![PyPI - Wheel](https://img.shields.io/pypi/wheel/ddns.svg?style=flat-square)

Pypi 安装当前版本或者更新最新版本

* 安装当前版本[current version]: `pip install ddns=${BUILD_SOURCEBRANCHNAME}`
* 安装当前版本[current version]: `pip install ddns=${BUILD_VERSION}`
* 更新最新版[update latest version]: `pip install -U ddns`
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
> 代理模式,支持自动创建域名记录。
[![PyPI](https://img.shields.io/pypi/v/ddns.svg?label=DDNS&style=social)](https://pypi.org/project/ddns/)
[![Build Status](https://github.com/NewFuture/DDNS/actions/workflows/python-build.yml/badge.svg?event=push)](https://github.com/NewFuture/DDNS/actions/workflows/build.yml)
[![Build Status](https://github.com/NewFuture/DDNS/actions/workflows/build.yml/badge.svg?event=push)](https://github.com/NewFuture/DDNS/actions/workflows/build.yml)
[![latest deploy](https://vsrm.dev.azure.com/NewFuture-CI/_apis/public/Release/badge/2ab09aad-c4b4-4c57-ab1b-2fb92c485664/1/1)](https://github.com/NewFuture/DDNS/releases/latest)

---
Expand Down
4 changes: 2 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from util.cache import Cache
from util.config import init_config, get_config

__version__ = "${BUILD_SOURCEBRANCHNAME}@${BUILD_DATE}" # CI 时会被Tag替换
__version__ = "${BUILD_VERSION}@${BUILD_DATE}" # CI 时会被Tag替换
__description__ = "automatically update DNS records to dynamic local IP [自动更新DNS记录指向本地IP]"
__doc__ = """
ddns[%s]
Expand All @@ -27,7 +27,7 @@
Copyright (c) New Future (MIT License)
""" % (__version__)

environ["DDNS_VERSION"] = "${BUILD_SOURCEBRANCHNAME}"
environ["DDNS_VERSION"] = "${BUILD_VERSION}"

if getattr(sys, 'frozen', False):
# https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OpenSSL-Certificate
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
ref = environ['GITHUB_REF_NAME']
if ref == 'master' or ref == 'main': # CI
version = '0.0.b' + str(int(time()))
elif ref.startswith('v') or ref.startswith('V'): # Tag
version = ref
else: # PR
version = '0.0.a1'
else:
Expand Down

0 comments on commit ecca037

Please sign in to comment.