diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml deleted file mode 100644 index b5581d41..00000000 --- a/.github/workflows/build-packages.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Build Debian Package - -on: - repository_dispatch: - types: [renterd-tagged] - workflow_dispatch: - inputs: - tag: - description: 'Tag to build' - required: true - default: 'v1.0.2' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - repository: SiaFoundation/renterd - ref: ${{ github.event.client_payload.tag }} - - - name: Build .deb Package - run: | - echo "Building renterd .deb packages for tag ${{ github.event.client_payload.tag }}" - go generate ./... - - for arch in amd64 arm64; do - # Make sure the right folder hierarchy exists for building the package - mkdir -p renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN - mkdir -p renterd${{ github.event.client_payload.tag }}_$arch/usr/bin - - # Build the renterd binary - GOOS=linux GOARCH=$arch go build -tags='netgo' -o renterd${{ github.event.client_payload.tag }}_$arch/usr/bin/renterd -a -ldflags='-s -w' ./cmd/renterd - - # Create the control file - echo "Package: renterd" > renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN/control - echo "Version: ${{ github.event.client_payload.tag }}" >> renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN/control - echo "Architecture: $arch" >> renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN/control - echo "Maintainer: The Sia Foundation " >> renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN/control - echo "Description: Renterd: The Next-Gen Sia Renter" >> renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN/control - echo "Homepage: https://github.com/SiaFoundation/renterd" >> renterd${{ github.event.client_payload.tag }}_$arch/DEBIAN/control - - # Build the .deb file - dpkg-deb --build renterd${{ github.event.client_payload.tag }}_$arch - - # Remove the temporary folders - rm -rf renterd${{ github.event.client_payload.tag }}_$arch - - # Move the .deb file to debian/pool/main/r/renterd - mv renterd${{ github.event.client_payload.tag }}_$arch.deb debian/pool/main/r/renterd/ - - # Update the Packages file - dpkg-scanpackages debian/pool/main/r/renterd/ /dev/null | gzip -9c > debian/dists/stable/main/binary-$arch/Packages.gz - done - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5.0.2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'renterd: ${{ github.event.client_payload.tag }}' - title: 'renterd: ${{ github.event.client_payload.tag }}' - body: 'This is an automated PR to update renterd to ${{ github.event.client_payload.tag }}' - branch: renterd/update - base: master \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08b5bd49..af9795a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,8 @@ name: Build Debian Package on: + repository_dispatch: + types: [release-tagged] workflow_dispatch: inputs: tag: @@ -16,5 +18,60 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Placeholder - run: echo "hello world" \ No newline at end of file + - name: Store input in env + run: | + echo "RELEASE_TAG=${{ github.event.client_payload.tag }}" >> $GITHUB_ENV + echo "PROJECT=${{ github.event.client_payload.project }}" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v3 + with: + repository: SiaFoundation/${{ env.PROJECT }} + ref: ${{ env.RELEASE_TAG }} + + - name: Build .deb Package + run: | + echo "Building ${{ env.PROJECT}} .deb packages for tag ${{ env.RELEASE_TAG }}" + go generate ./... + + for arch in amd64 arm64; do + # Declare the build id which is project_tag_arch + BUILD_NAME=${{ format('{0}_{1}', env.PROJECT, env.RELEASE_TAG) }}_$arch + + # Make sure the right folder hierarchy exists for building the package + mkdir -p $BUILD_NAME/DEBIAN + mkdir -p $BUILD_NAME/usr/bin + + # Build the ${{ env.PROJECT }} binary + GOOS=linux GOARCH=$arch go build -tags='netgo' -o $BUILD_NAME/usr/bin/${{ env.PROJECT }} -a -ldflags='-s -w' ./cmd/${{ env.PROJECT }} + + # Create the control file + echo "Package: ${{ env.PROJECT }}" > $BUILD_NAME/DEBIAN/control + echo "Version: ${{ env.RELEASE_TAG }}" >> $BUILD_NAME/DEBIAN/control + echo "Architecture: $arch" >> $BUILD_NAME/DEBIAN/control + echo "Maintainer: The Sia Foundation " >> $BUILD_NAME/DEBIAN/control + echo "Description: Renterd: The Next-Gen Sia Renter" >> $BUILD_NAME/DEBIAN/control + echo "Homepage: https://github.com/SiaFoundation/${{ env.PROJECT }}" >> $BUILD_NAME/DEBIAN/control + + # Build the .deb file + dpkg-deb --build $BUILD_NAME + + # Remove the temporary folders + rm -rf $BUILD_NAME + + # Move the .deb file to debian/pool/main/r/${{ env.PROJECT }} + mv $BUILD_NAME.deb debian/pool/main/r/${{ env.PROJECT }}/ + + # Update the Packages file + dpkg-scanpackages debian/pool/main/r/${{ env.PROJECT }}/ /dev/null | gzip -9c > debian/dists/stable/main/binary-$arch/Packages.gz + done + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5.0.2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: '${{ env.PROJECT }}: ${{ env.RELEASE_TAG }}' + title: '${{ env.PROJECT }}: ${{ env.RELEASE_TAG }}' + body: 'This is an automated PR to update ${{ env.PROJECT }} to ${{ env.RELEASE_TAG }}' + branch: ${{ env.PROJECT }}/update + base: master