Fixed error messages to print file with right extension name #6
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: publish-executable | |
on: | |
workflow_dispatch: null | |
push: | |
paths: | |
- 'cal.py' | |
branches: | |
- main | |
jobs: | |
build: | |
permissions: write-all | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pyinstaller | |
shell: pwsh | |
- name: Build executable | |
run: pyinstaller --onefile cal.py | |
shell: pwsh | |
- name: Get latest release tag | |
id: latest_release | |
run: | | |
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$env:GITHUB_REPOSITORY/releases/latest" -Headers @{Authorization = "Bearer $env:GITHUB_TOKEN"} | |
$old_tag = $response.tag_name | |
echo "::set-output name=tag_old::$old_tag" | |
$new_tag = (Get-Content cal.py | Select-String -Pattern 'program_version = "(.*)"').Matches.Groups[1].Value | |
echo "::set-output name=tag::v$new_tag" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Write new release body | |
id: new_release_body | |
run: | | |
$date_str = Get-Date | |
$body_str = 'Newest release as of ' + $date_str.ToString() + ' UTC.' | |
echo "::set-output name=content::$body_str" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.latest_release.outputs.tag }} | |
release_name: ${{ steps.latest_release.outputs.tag }} | |
body: ${{ steps.new_release_body.outputs.content }} | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist/cal.exe | |
asset_name: cal.exe | |
asset_content_type: application/octet-stream | |
- name: Update README.md | |
run: | | |
sed -i "s/${{ steps.latest_release.outputs.tag_old }}/${{ steps.latest_release.outputs.tag }}/g" README.md | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git commit -am "Updated README with installation of ${{ steps.latest_release.outputs.tag }}" | |
git push | |
shell: bash |