v20231025 - close #9 #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
create-release: | |
name: Create Release | |
outputs: | |
release_tag: ${{ steps.release_tag.outputs.release_tag }} | |
today: ${{ steps.release_tag.outputs.today }} | |
upload_url: ${{ steps.create_release.outputs.upload_url}} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TZ: "Asia/Tokyo" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# 前回のリリースタグを取得する | |
- name: Get previous tag | |
id: pre_tag | |
run: | | |
echo "pre_tag=$(curl -H 'Accept: application/vnd.github.v3+json' -H 'Authorization: token ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)" >> $GITHUB_OUTPUT | |
# タグを生成する 「{YYYY.MM.DD}」 | |
- name: Generate Tag | |
id: release_tag | |
run: | | |
today=$(date +'%Y.%m.%d') | |
echo "today=$today" >> $GITHUB_OUTPUT | |
echo "release_tag=v$today" >> $GITHUB_OUTPUT | |
- name: Delete Existing Tag | |
uses: dev-drprasad/delete-tag-and-release@v1.0 | |
if: steps.pre_tag.outputs.pre_tag == steps.release_tag.outputs.release_tag | |
with: | |
tag_name: ${{ steps.release_tag.outputs.release_tag }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
delete_release: true | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ steps.release_tag.outputs.release_tag }} | |
tag_name: ${{ steps.release_tag.outputs.release_tag }} | |
generate_release_notes: true | |
release-binary: | |
name: Build and Release Binary | |
needs: create-release | |
strategy: | |
matrix: | |
os: [windows-latest, ubuntu-latest] | |
include: | |
- os: windows-latest | |
goos: win | |
sed_cmd: | | |
$buf = Get-Content -Encoding UTF8 .\bilibili_downloader.py | % { $_ -replace "XXXX.XX.XX","${{ needs.create-release.outputs.today }}" } | |
$buf | Out-File -Encoding UTF8 .\bilibili_downloader.py | |
comp_cmd: powershell Compress-Archive *.exe,setting.* concat.zip | |
- os: ubuntu-latest | |
goos: linux | |
sed_cmd: | | |
fp=bilibili_downloader.py | |
sed -i -e "/__version__ =/c __version__ = '${{ needs.create-release.outputs.today }}'" ${fp} | |
comp_cmd: zip concat.zip *.bin setting.* | |
runs-on: ${{ matrix.os }} | |
steps: | |
# Buid EXE files | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set Version | |
run: ${{ matrix.sed_cmd }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install Pipenv | |
run: | | |
pip install --upgrade pip | |
pip install pipenv | |
- name: Install Dependencies | |
run: pipenv install --skip-lock --system | |
- name: Build with Nuitka | |
run: python -m nuitka --standalone --onefile --assume-yes-for-downloads bilibili_downloader.py | |
# Make a zip file | |
- name: Make ZIP files on Windows | |
run: ${{ matrix.comp_cmd }} | |
# Upload EXE files | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1.0.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: ./concat.zip | |
asset_name: BiDown_${{ needs.create-release.outputs.today }}_${{ matrix.goos }}.zip | |
asset_content_type: application/octet-stream |