|
| 1 | +name: "Release packages" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "master", "devel", "releases/v*" ] |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + pull_request: |
| 9 | + branches: [ "main", "master", "devel", "releases/v*" ] |
| 10 | + merge_group: |
| 11 | + branches: [ "main", "master", "devel", "releases/v*" ] |
| 12 | + |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | + |
| 20 | +jobs: |
| 21 | + lint: |
| 22 | + name: "Lint" |
| 23 | + runs-on: ubuntu-latest |
| 24 | + timeout-minutes: 30 |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - uses: dpc/nix-installer-action@dpc/jj-vqymqvyntouw |
| 28 | + - uses: cachix/cachix-action@v15 |
| 29 | + with: |
| 30 | + name: rostra |
| 31 | + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' |
| 32 | + continue-on-error: true |
| 33 | + |
| 34 | + - name: Check `nix flake show` |
| 35 | + run: nix flake show .# |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + pkg: |
| 40 | + name: "Build packages" |
| 41 | + runs-on: ubuntu-latest |
| 42 | + timeout-minutes: 30 |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - uses: dpc/nix-installer-action@dpc/jj-vqymqvyntouw |
| 46 | + - uses: cachix/cachix-action@v15 |
| 47 | + with: |
| 48 | + name: rostra |
| 49 | + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' |
| 50 | + continue-on-error: true |
| 51 | + |
| 52 | + |
| 53 | + - name: Set BUILD_ID to tag or commit hash |
| 54 | + run: | |
| 55 | + if [[ $GITHUB_REF_TYPE == "tag" ]]; then |
| 56 | + echo "BUILD_ID=${GITHUB_REF_NAME}" >> $GITHUB_ENV |
| 57 | + else |
| 58 | + echo "BUILD_ID=${GITHUB_SHA}" >> $GITHUB_ENV |
| 59 | + fi |
| 60 | +
|
| 61 | + - name: Build rostra |
| 62 | + env: |
| 63 | + # seems like cachix needs this explicitly set in the env |
| 64 | + CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_AUTH_TOKEN }}' |
| 65 | + run: | |
| 66 | + mkdir -p bins |
| 67 | + nix build -L .#rostra && sha256sum "./result/bin/rostra" |
| 68 | +
|
| 69 | + closure_size=$(nix path-info -rS --json .#rostra | jq '. | to_entries[] | select(.value.ultimate == true) | .value.narSize') |
| 70 | + >&2 echo "rostra's Nix closure size: $closure_size" |
| 71 | +
|
| 72 | + if [ 100000000 -lt $closure_size ]; then |
| 73 | + >&2 echo "rostra's Nix closure size seems too big: $closure_size" |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | +
|
| 77 | + nix bundle --bundler .# ".#rostra" -o "bins/rostra-$BUILD_ID" && sha256sum "bins/rostra-$BUILD_ID" |
| 78 | +
|
| 79 | + - name: Upload Binaries |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: "rostra-linux-x86_64" |
| 83 | + path: "bins/**" |
| 84 | + |
| 85 | + - name: Release Binaries |
| 86 | + uses: softprops/action-gh-release@v2 |
| 87 | + if: startsWith(github.ref, 'refs/tags/') |
| 88 | + with: |
| 89 | + files: "bins/**" |
| 90 | + prerelease: ${{ contains(github.ref, 'rc') }} |
| 91 | + body: ${{ contains(github.ref, 'rc') && env.PRERELEASE_MESSAGE || '' }} |
| 92 | + |
| 93 | + - name: Build DEB package |
| 94 | + run: | |
| 95 | + nix bundle -L --bundler .#toDEB --accept-flake-config -o debs/rostra .#rostra |
| 96 | + # workaround: https://github.com/actions/upload-artifact/issues/92 |
| 97 | + cp -a debs/rostra/*.deb debs/ |
| 98 | +
|
| 99 | + - name: Build RPM package |
| 100 | + run: | |
| 101 | + nix bundle -L --bundler .#toRPM --accept-flake-config -o rpms/rostra .#rostra |
| 102 | + # workaround: https://github.com/actions/upload-artifact/issues/92 |
| 103 | + cp -a rpms/rostra/*.rpm rpms/ |
| 104 | +
|
| 105 | + - name: Upload DEB packages |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: "rostra-deb-bundle" |
| 109 | + path: "debs/**.deb" |
| 110 | + |
| 111 | + - name: Release DEB packages |
| 112 | + uses: softprops/action-gh-release@v2 |
| 113 | + if: startsWith(github.ref, 'refs/tags/') |
| 114 | + with: |
| 115 | + files: "debs/**.deb" |
| 116 | + prerelease: ${{ contains(github.ref, 'rc') }} |
| 117 | + body: ${{ contains(github.ref, 'rc') && env.PRERELEASE_MESSAGE || '' }} |
| 118 | + |
| 119 | + - name: Upload RPM packages |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: "rostra-rpm-bundle" |
| 123 | + path: "rpms/**.rpm" |
| 124 | + |
| 125 | + - name: Release RPM packages |
| 126 | + uses: softprops/action-gh-release@v2 |
| 127 | + if: startsWith(github.ref, 'refs/tags/') |
| 128 | + with: |
| 129 | + files: "rpms/**.rpm" |
| 130 | + prerelease: ${{ contains(github.ref, 'rc') }} |
| 131 | + body: ${{ contains(github.ref, 'rc') && env.PRERELEASE_MESSAGE || '' }} |
0 commit comments