parametrized port and host #13
Workflow file for this run
This file contains hidden or 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: release | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| env: | |
| PYTHON_VERSION: "3.9" | |
| PROGRAM_ENTRYPOINT: 'src/app.py' | |
| EXECUTABLE_NAME: 'hackernewsd' | |
| BUILD_OUTPUT_PATH: 'dist' | |
| jobs: | |
| build-windows: | |
| runs-on: windows-2019 | |
| outputs: | |
| release-upload-url: ${{ steps.release.outputs.upload_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v1 | |
| - name: Install Python | |
| uses: actions/setup-python@v1 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| architecture: 'x64' | |
| - name: Get version | |
| id: version | |
| uses: battila7/get-version-action@v2 | |
| - name: Install requirements | |
| run: pip install -r requirements.txt | |
| - name: Run PyInstaller | |
| run: pip install pyinstaller; pyinstaller --noconsole --onefile --name=${{ env.EXECUTABLE_NAME }} ${{ env.PROGRAM_ENTRYPOINT }} | |
| - name: ZIP release artifact Windows | |
| run: echo $(pwd); cd ${{ env.BUILD_OUTPUT_PATH }}; Compress-Archive -Path ./* -DestinationPath ../${{ env.EXECUTABLE_NAME }}-${{ steps.version.outputs.version }}-win64.zip | |
| - name: GitHub release | |
| uses: actions/create-release@v1 | |
| id: release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| release_name: ${{ steps.version.outputs.version }} | |
| tag_name: ${{ github.ref }} | |
| body: '' | |
| draft: false | |
| prerelease: false | |
| - name: GitHub release assets Windows | |
| uses: actions/upload-release-asset@v1 | |
| id: release_assets_2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.release.outputs.upload_url }} | |
| asset_path: ${{ env.BUILD_OUTPUT_PATH }}/../${{ env.EXECUTABLE_NAME }}-${{ steps.version.outputs.version }}-win64.zip | |
| asset_name: ${{ env.EXECUTABLE_NAME }}-${{ steps.version.outputs.version }}-win64.zip | |
| asset_content_type: application/zip | |
| build-linux: | |
| needs: build-windows #this job will run only after build-windows. This way, build-windows creates the Release, and build-linux only adds an asset to it, thus avoiding a race ccondition. | |
| runs-on: ubuntu-20.04 | |
| env: | |
| RELEASE_UPLOAD_URL: ${{ needs.build-windows.outputs.release-upload-url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v1 | |
| - name: Install Python | |
| uses: actions/setup-python@v1 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| architecture: 'x64' | |
| - name: Get version | |
| id: version | |
| uses: battila7/get-version-action@v2 | |
| - name: Install requirements | |
| run: pip install -r requirements.txt | |
| - name: Run PyInstaller | |
| run: pip install pyinstaller; pyinstaller --noconsole --onefile --name=${{ env.EXECUTABLE_NAME }} ${{ env.PROGRAM_ENTRYPOINT }} | |
| - name: ZIP release artifact Linux | |
| run: echo $(pwd); echo $(find . -type d); cd ${{ env.BUILD_OUTPUT_PATH }}; zip -r ../${{ env.EXECUTABLE_NAME }}-${{ steps.version.outputs.version }}-linux64.zip ./ | |
| - name: GitHub release assets Linux | |
| uses: actions/upload-release-asset@v1 | |
| id: release_assets_2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ env.RELEASE_UPLOAD_URL }} | |
| asset_path: ${{ env.BUILD_OUTPUT_PATH }}/../${{ env.EXECUTABLE_NAME }}-${{ steps.version.outputs.version }}-linux64.zip | |
| asset_name: ${{ env.EXECUTABLE_NAME }}-${{ steps.version.outputs.version }}-linux64.zip | |
| asset_content_type: application/zip |