diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df423fb2..0bbe1d6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,11 @@ jobs: - name: Install dependencies run: | - apt update && apt install -y unzip dpkg-dev git + apt update && apt install -y unzip dpkg-dev git reprepro + + - name: Import GPG Key + run: | + echo "${{ secrets.GPG_SIGNING_KEY }}" | base64 --decode | gpg --import - name: Checkout repo uses: actions/checkout@v3 @@ -57,74 +61,73 @@ jobs: repo: SiaFoundation/${{ env.PROJECT }} run_id: ${{ env.WORKFLOW_ID }} workflow_conclusion: success - - - - name: Build .deb Package + + - name: Build .deb packages shell: bash run: | TAG=${{ env.RELEASE_TAG }} VERSION=${TAG:1} for arch in amd64 arm64; do - BUILD_NAME=${{ env.PROJECT }}_${VERSION}_${arch} - - # Create the directory structure for the .deb package - mkdir -p ${BUILD_NAME}/DEBIAN - mkdir -p ${BUILD_NAME}/usr/bin - mkdir -p ${BUILD_NAME}/etc/systemd/system - - # Copy the ${{ env.PROJECT }} binary - unzip ./artifacts/${{ env.PROJECT }}_linux_${arch}.zip -d ./artifacts/${arch}/ - cp ./artifacts/${arch}/${{ env.PROJECT }} ${BUILD_NAME}/usr/bin/${{ env.PROJECT }} - - # Create the control file - echo "Package: ${{ env.PROJECT }}" > ${BUILD_NAME}/DEBIAN/control - echo "Version: $VERSION" >> ${BUILD_NAME}/DEBIAN/control - echo "Architecture: ${arch}" >> ${BUILD_NAME}/DEBIAN/control - echo "Maintainer: The Sia Foundation " >> ${BUILD_NAME}/DEBIAN/control - echo "Description: ${DESCRIPTION}" >> ${BUILD_NAME}/DEBIAN/control - echo "Homepage: https://github.com/SiaFoundation/${{ env.PROJECT }}" >> ${BUILD_NAME}/DEBIAN/control - - # Create systemd service file - echo "[Unit]" > ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "Description=${DESCRIPTION}" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "After=network.target" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - - echo "[Service]" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "ExecStart=/usr/bin/${{ env.PROJECT }}" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "WorkingDirectory=/var/lib/${{ env.PROJECT }}" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "Restart=always" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "RestartSec=15" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - - echo "[Install]" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "WantedBy=multi-user.target" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - echo "Alias=${{ env.PROJECT }}.service" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service - - # Create the prerem script - echo "#!/bin/sh" > ${BUILD_NAME}/DEBIAN/prerm - echo "systemctl stop ${{ env.PROJECT }}.service" >> ${BUILD_NAME}/DEBIAN/prerm - echo "systemctl disable ${{ env.PROJECT }}.service" >> ${BUILD_NAME}/DEBIAN/prerm - chmod +x ${BUILD_NAME}/DEBIAN/prerm - - # Build the .deb file - echo "Building ${BUILD_NAME}.deb" - dpkg-deb --build ${BUILD_NAME} - - # Move the .deb file - mkdir -p ./debian/pool/main/${{ env.PROJECT }} - mv ${BUILD_NAME}.deb ./debian/pool/main/${{ env.PROJECT }}/ - - # Remove the temporary folders - rm -rf ${BUILD_NAME} - - # Update the Packages file - mkdir -p debian/dists/stable/main/binary-${arch} - dpkg-scanpackages ./debian/pool/main/ | gzip -c > debian/dists/stable/main/binary-${arch}/Packages.gz + BUILD_NAME=${{ env.PROJECT }}_${VERSION}_${arch} + + # Create the directory structure for the .deb package + mkdir -p ${BUILD_NAME}/DEBIAN + mkdir -p ${BUILD_NAME}/usr/bin + mkdir -p ${BUILD_NAME}/etc/systemd/system + + # Copy the ${{ env.PROJECT }} binary + unzip ./artifacts/${{ env.PROJECT }}_linux_${arch}.zip -d ./artifacts/${arch}/ + cp ./artifacts/${arch}/${{ env.PROJECT }} ${BUILD_NAME}/usr/bin/${{ env.PROJECT }} + + # Create the control file + echo "Package: ${{ env.PROJECT }}" > ${BUILD_NAME}/DEBIAN/control + echo "Version: $VERSION" >> ${BUILD_NAME}/DEBIAN/control + echo "Architecture: ${arch}" >> ${BUILD_NAME}/DEBIAN/control + echo "Maintainer: The Sia Foundation " >> ${BUILD_NAME}/DEBIAN/control + echo "Priority: optional" >> ${BUILD_NAME}/DEBIAN/control + echo "Section: net" >> ${BUILD_NAME}/DEBIAN/control + echo "Description: ${DESCRIPTION}" >> ${BUILD_NAME}/DEBIAN/control + echo "Homepage: https://github.com/SiaFoundation/${{ env.PROJECT }}" >> ${BUILD_NAME}/DEBIAN/control + + # Create systemd service file + echo "[Unit]" > ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "Description=${DESCRIPTION}" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "After=network.target" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + + echo "[Service]" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "ExecStart=/usr/bin/${{ env.PROJECT }}" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "WorkingDirectory=/var/lib/${{ env.PROJECT }}" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "Restart=always" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "RestartSec=15" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + + echo "[Install]" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "WantedBy=multi-user.target" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + echo "Alias=${{ env.PROJECT }}.service" >> ${BUILD_NAME}/etc/systemd/system/${{ env.PROJECT }}.service + + # Create the prerem script + echo "#!/bin/sh" > ${BUILD_NAME}/DEBIAN/prerm + echo "systemctl stop ${{ env.PROJECT }}.service" >> ${BUILD_NAME}/DEBIAN/prerm + echo "systemctl disable ${{ env.PROJECT }}.service" >> ${BUILD_NAME}/DEBIAN/prerm + chmod +x ${BUILD_NAME}/DEBIAN/prerm + + # Build the .deb file + echo "Building ${BUILD_NAME}.deb" + dpkg-deb --build ${BUILD_NAME} + + # Remove the folder + rm -rf ${BUILD_NAME} done - # Delete artifacts folder + - name: Add packages to repository + run: | + reprepro -Vb ./debian includedeb stable *.deb + + - name: Clean up + run: | + rm *.deb rm -rf ./artifacts - name: Create Pull Request diff --git a/README.md b/README.md index 0eaa2039..283fa1d8 100644 --- a/README.md +++ b/README.md @@ -11,5 +11,6 @@ The following packages are supported Simply add this repo to your sources by running the following command ```bash -echo "deb [trusted=yes] https://linux.sia.tech/debian stable main" | sudo tee -a /etc/apt/sources.list.d/siafoundation.list +sudo curl -fsSL https://linux.sia.tech/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/siafoundation.gpg +echo "deb [signed-by=/usr/share/keyrings/siafoundation.gpg] https://linux.sia.tech/debian stable main" | sudo tee -a /etc/apt/sources.list.d/siafoundation.list ``` diff --git a/debian/conf/distributions b/debian/conf/distributions new file mode 100644 index 00000000..00c4b786 --- /dev/null +++ b/debian/conf/distributions @@ -0,0 +1,5 @@ +Codename: stable +Architectures: amd64 arm64 +Components: main +Description: The official home of Sia's Debian packages +SignWith: yes \ No newline at end of file diff --git a/debian/gpg b/debian/gpg new file mode 100644 index 00000000..9055821d --- /d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