|
| 1 | +name: release |
| 2 | +# Based on https://github.com/ra3xdh/qucs_s/.github/workflows/deploy.yml |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + |
| 9 | +env: |
| 10 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-debian-packages: |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + os_name: ['bullseye', 'bookworm', 'trixie'] |
| 19 | + container: |
| 20 | + # https://hub.docker.com/_/debian |
| 21 | + image: debian:${{matrix.os_name}} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: 'Install Dependencies' |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + apt-get update |
| 29 | + # https://serverfault.com/a/992421 |
| 30 | + DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y build-essential qtbase5-dev qttools5-dev-tools libqt5serialport5-dev |
| 31 | +
|
| 32 | + - name: 'Build' |
| 33 | + shell: bash |
| 34 | + run: install/deb-build.sh -s debian-${{matrix.os_name}} -v ${{ github.ref_name }} |
| 35 | + |
| 36 | + - name: 'Upload debian packages' |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: debian-${{matrix.os_name}} |
| 40 | + path: '*.deb' |
| 41 | + |
| 42 | + build-ubuntu-packages: |
| 43 | + runs-on: ubuntu-22.04 |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + os_name: ['focal', 'jammy', 'mantic', 'noble'] |
| 48 | + container: |
| 49 | + # https://hub.docker.com/_/ubuntu |
| 50 | + image: ubuntu:${{matrix.os_name}} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: 'Install Dependencies' |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + apt-get update |
| 58 | + DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y build-essential qtbase5-dev qttools5-dev-tools libqt5serialport5-dev |
| 59 | +
|
| 60 | + - name: 'Build' |
| 61 | + shell: bash |
| 62 | + run: install/deb-build.sh -s ubuntu-${{matrix.os_name}} -v ${{ github.ref_name }} |
| 63 | + |
| 64 | + - name: 'Upload ubuntu packages' |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: ubuntu-${{matrix.os_name}} |
| 68 | + path: '*.deb' |
| 69 | + |
| 70 | + create-release: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: [build-debian-packages, build-ubuntu-packages] |
| 73 | + steps: |
| 74 | + - name: Download build artifacts |
| 75 | + uses: actions/download-artifact@v4 |
| 76 | + with: |
| 77 | + path: ~/artifacts |
| 78 | + merge-multiple: true |
| 79 | + |
| 80 | + - name: Calculate SHA-256 checksums |
| 81 | + run: | |
| 82 | + cd ~/artifacts |
| 83 | + echo 'SHA-256 checksums' > notes.txt |
| 84 | + echo '-----------------' >> notes.txt |
| 85 | + echo -e '\n```' >> notes.txt |
| 86 | + for file in $(find . -type f \( -name "*.exe" -o -name "*.zip" -o -name "*.deb" -o -name "*.rpm" \) | sort); do |
| 87 | + filename=$(basename "$file") |
| 88 | + checksum=$(sha256sum "$file" | awk '{print $1}') |
| 89 | + echo "$checksum $filename" >> notes.txt |
| 90 | + #echo $checksum > "$filename".sha256 |
| 91 | + done |
| 92 | + echo -e '```\n' >> notes.txt |
| 93 | + cd .. |
| 94 | + tree ~/artifacts |
| 95 | +
|
| 96 | + - name: Setup Release Information |
| 97 | + run: | |
| 98 | + echo "RELEASE_NAME=${{ github.ref_name }}" >> $GITHUB_ENV |
| 99 | + echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV |
| 100 | + echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV |
| 101 | + |
| 102 | + - name: Create GitHub Release |
| 103 | + continue-on-error: false |
| 104 | + run: | |
| 105 | + # Find existing artifact files |
| 106 | + hash_files=$(find ~/artifacts -name "*.sha256" -print0 | xargs -0 echo) |
| 107 | + exe_files=$(find ~/artifacts -name "*.exe" -print0 | xargs -0 echo) |
| 108 | + zip_files=$(find ~/artifacts -name "*.zip" -print0 | xargs -0 echo) |
| 109 | + deb_files=$(find ~/artifacts -name "*.deb" -print0 | xargs -0 echo) |
| 110 | + rpm_files=$(find ~/artifacts -name "*.rpm" -print0 | xargs -0 echo) |
| 111 | +
|
| 112 | + # Check existing release and delete if it's exist |
| 113 | + if gh release view ${{ env.TAG_NAME }} --repo $GITHUB_REPOSITORY &> /dev/null; then |
| 114 | + gh release delete ${{ env.TAG_NAME }} --repo $GITHUB_REPOSITORY |
| 115 | + echo "${{ env.TAG_NAME }} deleted!" |
| 116 | + fi |
| 117 | +
|
| 118 | + gh release create ${{ env.TAG_NAME }} \ |
| 119 | + --repo $GITHUB_REPOSITORY \ |
| 120 | + --draft \ |
| 121 | + --title "${{ env.RELEASE_NAME }}" \ |
| 122 | + --notes-file ~/artifacts/notes.txt \ |
| 123 | + $hash_files \ |
| 124 | + $exe_files \ |
| 125 | + $zip_files \ |
| 126 | + $deb_files \ |
| 127 | + $rpm_files |
| 128 | + |
| 129 | + env: |
| 130 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments