|
| 1 | +name: Update deb repo |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + generate-repo: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Install reprepro |
| 15 | + run: sudo apt-get update && sudo apt-get install -y reprepro |
| 16 | + |
| 17 | + - name: Import GPG key |
| 18 | + env: |
| 19 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 20 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 21 | + run: | |
| 22 | + mkdir -p ~/.gnupg |
| 23 | + echo "allow-preset-passphrase" >> ~/.gnupg/gpg-agent.conf |
| 24 | + gpg-connect-agent reloadagent /bye |
| 25 | + echo "$GPG_PRIVATE_KEY" \ |
| 26 | + | gpg --batch --pinentry-mode loopback \ |
| 27 | + --passphrase "$GPG_PASSPHRASE" --import |
| 28 | +
|
| 29 | + # preset passphrase in agent so reprepro can sign |
| 30 | + gpg --list-secret-keys --with-keygrip --with-colons \ |
| 31 | + | awk -F: '/grp/{print $10}' \ |
| 32 | + | while read -r keygrip; do |
| 33 | + /usr/lib/gnupg/gpg-preset-passphrase \ |
| 34 | + --preset --passphrase "$GPG_PASSPHRASE" "$keygrip" |
| 35 | + done |
| 36 | +
|
| 37 | + - name: Set up reprepro |
| 38 | + run: | |
| 39 | + mkdir -p repo/conf |
| 40 | +
|
| 41 | + cat > repo/conf/distributions <<'EOF' |
| 42 | + Origin: imput |
| 43 | + Label: Helium |
| 44 | + Description: Helium .deb repository |
| 45 | + Codename: stable |
| 46 | + Architectures: amd64 arm64 |
| 47 | + Components: main |
| 48 | + SignWith: default |
| 49 | +
|
| 50 | + Origin: imput |
| 51 | + Label: Helium |
| 52 | + Description: Helium .deb repository |
| 53 | + Codename: prerelease |
| 54 | + Architectures: amd64 arm64 |
| 55 | + Components: main |
| 56 | + SignWith: default |
| 57 | + EOF |
| 58 | +
|
| 59 | + cat > repo/conf/options <<'EOF' |
| 60 | + verbose |
| 61 | + basedir . |
| 62 | + EOF |
| 63 | +
|
| 64 | + - name: Download and add .deb packages |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ github.token }} |
| 67 | + run: | |
| 68 | + cd repo |
| 69 | +
|
| 70 | + stable_tag=$( |
| 71 | + gh release list \ |
| 72 | + --repo "$GITHUB_REPOSITORY" \ |
| 73 | + --exclude-pre-releases \ |
| 74 | + --limit 1 \ |
| 75 | + --json tagName \ |
| 76 | + --jq '.[0].tagName' |
| 77 | + ) |
| 78 | +
|
| 79 | + prerelease_tag=$( |
| 80 | + gh release list \ |
| 81 | + --repo "$GITHUB_REPOSITORY" \ |
| 82 | + --limit 1 \ |
| 83 | + --json tagName \ |
| 84 | + --jq '.[0].tagName' |
| 85 | + ) |
| 86 | +
|
| 87 | + if [ -z "$stable_tag" ] || [ "$stable_tag" = "null" ]; then |
| 88 | + echo "::error::No stable release found" |
| 89 | + exit 1 |
| 90 | + fi |
| 91 | +
|
| 92 | + if [ -z "$prerelease_tag" ] || [ "$prerelease_tag" = "null" ]; then |
| 93 | + echo "::error::No release found" |
| 94 | + exit 1 |
| 95 | + fi |
| 96 | +
|
| 97 | + echo "::group::Adding stable ($stable_tag)" |
| 98 | + mkdir -p /tmp/stable |
| 99 | + gh release download "$stable_tag" \ |
| 100 | + --repo "$GITHUB_REPOSITORY" \ |
| 101 | + --pattern "*.deb" \ |
| 102 | + --dir /tmp/stable |
| 103 | + for deb in /tmp/stable/*.deb; do |
| 104 | + reprepro -S web includedeb stable "$deb" |
| 105 | + done |
| 106 | + echo "::endgroup::" |
| 107 | +
|
| 108 | + echo "::group::Adding prerelease ($prerelease_tag)" |
| 109 | + mkdir -p /tmp/prerelease |
| 110 | + gh release download "$prerelease_tag" \ |
| 111 | + --repo "$GITHUB_REPOSITORY" \ |
| 112 | + --pattern "*.deb" \ |
| 113 | + --dir /tmp/prerelease |
| 114 | + for deb in /tmp/prerelease/*.deb; do |
| 115 | + reprepro -S web includedeb prerelease "$deb" |
| 116 | + done |
| 117 | + echo "::endgroup::" |
| 118 | +
|
| 119 | + - name: Create artifact |
| 120 | + run: | |
| 121 | + rm -rf repo/conf repo/db |
| 122 | + tar -czf deb-repo.tar.gz -C repo . |
| 123 | +
|
| 124 | + - name: Upload artifact |
| 125 | + uses: actions/upload-artifact@v7 |
| 126 | + with: |
| 127 | + name: deb-repo |
| 128 | + path: deb-repo.tar.gz |
| 129 | + archive: false |
0 commit comments