add release step #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: Build and Release | |
on: | |
push: | |
branches: | |
- Main | |
- feature/github-actions | |
create: | |
tags: | |
- "v*" # Trigger on new tags | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.upload_url.outputs.upload_url }} | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout repository | |
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 | |
pip install -r requirements.txt | |
- name: Determine version | |
id: version | |
run: echo "::set-output name=version::$(if [ -n "$GITHUB_REF" ]; then echo $GITHUB_REF | awk -F/ '{print $3}'; else echo "1.0.$(git rev-list --count HEAD)-$(echo ${{ github.sha }} | head -c7)"; fi)" | |
- name: Build executable | |
run: | | |
pyinstaller --onefile app.py --name mimosa | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: mimosa | |
path: dist/mimosa/mimosa.exe | |
- name: Upload URL generation | |
id: upload_url | |
run: echo "upload_url=$(echo ${{ github.event.repository.releases.url }} | sed 's/{\/id}//')" >> $GITHUB_ENV | |
docker: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile # Replace with the path to your Dockerfile | |
platforms: linux/amd64,linux/arm64 # Adjust the platforms as needed | |
push: true | |
tags: | | |
tpickett/mimosa:latest | |
tpickett/mimosa:${{ needs.build.outputs.version }} | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.build.outputs.version }} | |
release_name: ${{ needs.build.outputs.version }} | |
overwrite: true | |
body: | | |
Test Release ${{ needs.build.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ needs.build.outputs.upload_url }} | |
asset_path: ./dist/mimosa | |
asset_name: mimosa.exe | |
asset_content_type: application/octet-stream | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |