Merge pull request #172 from masqu3rad3/dev #39
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: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: pip install -r ./package/requirements.txt | |
# - name: Generate Release Notes from PRs | |
# uses: actions/github-script@v6 | |
# id: generate_pr_notes | |
# with: | |
# script: | | |
# const { data: pulls } = await github.rest.pulls.list({ | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# state: "closed", | |
# base: context.ref | |
# }); | |
# const notes = pulls | |
# .filter(pr => pr.merged_at) | |
# .map(pr => `- ${pr.title} (#${pr.number})`) | |
# .join("\n"); | |
# return notes; | |
# result-encoding: string | |
- name: Install Inno Setup | |
run: | | |
curl -L -o innosetup.exe "https://jrsoftware.org/download.php/is.exe" | |
cmd /c "innosetup.exe /VERYSILENT /NORESTART" | |
- name: Extract Version from _version.py | |
id: extract_version | |
run: | | |
$VERSION = python -c "from tik_manager4 import _version; print(_version.__version__)" | |
echo "VERSION=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 | |
shell: pwsh | |
- name: Debug Version | |
run: echo "Extracted version is ${{ env.VERSION }}" | |
- name: Check if Release Tag Exists | |
id: check_tag | |
run: | | |
git fetch --tags | |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then | |
echo "Error: Tag v${{ env.VERSION }} already exists." | |
exit 1 | |
fi | |
shell: bash | |
- name: Build and Package | |
run: | | |
cd package | |
./make release | |
- name: List Build Directory | |
run: dir package\build | |
shell: cmd | |
- name: Verify the Built File | |
run: | | |
if not exist "package\build\TikManager4_v${{ env.VERSION }}.exe" exit 1 | |
shell: cmd | |
- name: Read Sanitized Release Notes | |
id: read_release_notes | |
run: | | |
sanitized_notes_file="package/build/ReleaseNotes_v${{ env.VERSION }}.md" | |
if [ ! -f "$sanitized_notes_file" ]; then | |
echo "Error: Sanitized release notes not found: $sanitized_notes_file" | |
exit 1 | |
fi | |
release_notes=$(cat "$sanitized_notes_file") | |
echo "release_notes<<EOF" >> $GITHUB_ENV | |
echo "$release_notes" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
shell: bash | |
- name: Upload Release Assets | |
uses: actions/upload-artifact@v3 | |
with: | |
name: TikManager4 | |
path: package/build/TikManager4_v${{ env.VERSION }}.exe | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: package/build/TikManager4_v${{ env.VERSION }}.exe | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: v${{ env.VERSION }} | |
name: v${{ env.VERSION }} | |
body: | | |
## What's Changed | |
${{ env.release_notes }} |