meetup 7/11/24 #11
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: Create Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11.1' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pyinstaller | |
- name: Build the project | |
run: | | |
pyinstaller --noconfirm --onedir --windowed --icon "$(pwd)/content_scheduler/socialmediascheduler/logo.ico" \ | |
--paths "$(pwd)/content_scheduler/socialmediascheduler/gui" \ | |
--paths "$(pwd)/content_scheduler/socialmediascheduler/scheduler" \ | |
--paths "$(pwd)/content_scheduler/socialmediascheduler/controller" \ | |
"manage.py" | |
- name: Copy additional files | |
run: | | |
cp sample.env dist/manage/sample.env | |
cp config.yaml dist/manage/config.yaml | |
cp logo.png dist/manage/logo.png | |
cp database_default.sqlite3 dist/manage/database_default.sqlite3 | |
- name: Zip the manage folder | |
run: | | |
cd dist | |
zip -r manage.zip manage | |
echo "MANAGE_ZIP_PATH=$(pwd)/manage.zip" >> $GITHUB_ENV | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: my-app | |
path: dist/manage.zip | |
create_release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Download build artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: my-app | |
- name: List current directory | |
run: ls -R | |
- name: Print environment variables | |
run: env | |
- name: Generate release name and tag | |
id: generate_release_info | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
if [[ "$COMMIT_MESSAGE" =~ ^Release.* ]]; then | |
TAG_NAME=$(echo "$COMMIT_MESSAGE" | awk '{print $2}') | |
RELEASE_NAME=$(echo "$COMMIT_MESSAGE" | awk '{$1=""; print $0}') | |
else | |
TAG_NAME="release-$(date +'%Y%m%d%H%M%S')" | |
RELEASE_NAME="Release $(date +'%Y-%m-%d %H:%M:%S')" | |
fi | |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV | |
shell: bash | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
release_name: ${{ env.RELEASE_NAME }} | |
draft: false | |
prerelease: false | |
- name: List current directory | |
run: ls -R | |
- name: 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: manage.zip | |
asset_name: manage.zip | |
asset_content_type: application/zip |