Build release artefacts #49
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: Build release artefacts | |
| run-name: Build release artefacts | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| create-archive: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create archive | |
| run: | | |
| set -x | |
| APP_VERSION=$GITHUB_SHA | |
| if [ "$GITHUB_REF_TYPE" = "tag" ] ; then | |
| APP_VERSION=`echo $GITHUB_REF_NAME | cut -dv -f2-` | |
| fi | |
| git archive --format=tar.gz --prefix=neknihy-$APP_VERSION/ HEAD >neknihy-$APP_VERSION.tar.gz | |
| echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_ENV" | |
| - name: Upload tar archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tar | |
| path: neknihy-*.tar.gz | |
| retention-days: 5 | |
| build-rpm: | |
| runs-on: ubuntu-latest | |
| container: fedora:latest | |
| needs: create-archive | |
| steps: | |
| - name: Download tar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tar | |
| - name: Install dependencies | |
| run: | | |
| dnf -y install rpm-build python3-devel git | |
| - name: Build rpm | |
| run: | | |
| set -x | |
| APP_VERSION=$GITHUB_SHA | |
| if [ "$GITHUB_REF_TYPE" = "tag" ] ; then | |
| APP_VERSION=`echo $GITHUB_REF_NAME | cut -dv -f2-` | |
| fi | |
| echo $APP_VERSION | |
| rpmbuild -D "SRCVERSION $APP_VERSION" -D "_rpmdir $(pwd)/rpm" -ta neknihy-*.tar.gz | |
| mv rpm/noarch/*.rpm ./ | |
| - name: Upload rpm | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rpm | |
| path: neknihy-*.rpm | |
| retention-days: 5 | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create Executable | |
| uses: sayyid5416/pyinstaller@v1 | |
| with: | |
| spec: 'src/neknihy.py' | |
| requirements: 'src/REQUIREMENTS.txt' | |
| options: --add-data src/resources:resources --icon src/resources/neknihy.ico -w | |
| upload_exe_with_name: 'exe' | |
| repack-zip: | |
| runs-on: ubuntu-latest | |
| needs: [build-windows] | |
| steps: | |
| - name: Install packages | |
| run: | | |
| sudo apt-get install --yes zip | |
| - name: Download exe | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: exe | |
| path: windows | |
| - name: Make zip | |
| run: | | |
| APP_VERSION=$GITHUB_SHA | |
| if [ "$GITHUB_REF_TYPE" = "tag" ] ; then | |
| APP_VERSION=`echo $GITHUB_REF_NAME | cut -dv -f2-` | |
| fi | |
| pushd windows/neknihy | |
| zip -r ../../neknihy-win-$APP_VERSION.zip * | |
| popd | |
| - name: Upload win-zip archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: win-zip | |
| path: neknihy-win-*.zip | |
| retention-days: 5 | |
| release-articacts: | |
| permissions: write-all | |
| runs-on: ubuntu-latest | |
| needs: [create-archive, build-rpm, repack-zip] | |
| steps: | |
| - name: Download tar | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tar | |
| - name: Download rpm | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: rpm | |
| - name: Download windows zip | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: win-zip | |
| - name: Detect exact file names | |
| run: | | |
| echo "APP_TAR=`ls neknihy*.tar.gz`" >> "$GITHUB_ENV" | |
| echo "APP_RPM=`ls neknihy*.rpm`" >> "$GITHUB_ENV" | |
| echo "APP_WIN_ZIP=`ls neknihy-win*.zip`" >> "$GITHUB_ENV" | |
| - name: Upload rpm to release | |
| uses: JasonEtco/upload-to-release@master | |
| with: | |
| args: ${{ env.APP_RPM }} application/octet-stream | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload tar to release | |
| uses: JasonEtco/upload-to-release@master | |
| with: | |
| args: ${{ env.APP_TAR }} application/octet-stream | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload windows zip to release | |
| uses: JasonEtco/upload-to-release@master | |
| with: | |
| args: ${{ env.APP_WIN_ZIP }} application/octet-stream | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |