|
| 1 | +name: APT Repository Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + # Allow manual triggering for testing |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + release_tag: |
| 10 | + description: 'Release tag (e.g., v1.2.3)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +env: |
| 15 | + DEBIAN_FRONTEND: noninteractive |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: recursive |
| 25 | + |
| 26 | + - name: Set up dependencies |
| 27 | + run: | |
| 28 | + sudo apt-get -qq update |
| 29 | + sudo apt-get install -y libelf-dev libssl-dev libcap-dev ruby-dev build-essential |
| 30 | + |
| 31 | + - name: Install FPM |
| 32 | + run: | |
| 33 | + sudo gem install fpm |
| 34 | +
|
| 35 | + - name: Set release tag |
| 36 | + id: release_tag |
| 37 | + run: | |
| 38 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 39 | + echo "tag=${{ github.event.inputs.release_tag }}" >> $GITHUB_OUTPUT |
| 40 | + else |
| 41 | + echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Build .deb package |
| 45 | + run: | |
| 46 | + # FPM is already installed in CI, so skip gem install |
| 47 | + FPM_SKIP_INSTALL=1 ./scripts/build-deb.sh ${{ steps.release_tag.outputs.tag }} |
| 48 | +
|
| 49 | + - name: Upload .deb artifact |
| 50 | + uses: actions/upload-artifact@v4 |
| 51 | + with: |
| 52 | + name: deb-package |
| 53 | + path: artifacts/*.deb |
| 54 | + retention-days: 30 |
| 55 | + |
| 56 | + publish: |
| 57 | + needs: build |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - name: Checkout gh-pages branch |
| 61 | + uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + ref: gh-pages |
| 64 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + |
| 66 | + - name: Install reprepro |
| 67 | + run: | |
| 68 | + sudo apt-get update |
| 69 | + sudo apt-get install -y reprepro |
| 70 | +
|
| 71 | + - name: Download .deb artifact |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + name: deb-package |
| 75 | + path: ./artifacts |
| 76 | + |
| 77 | + - name: Set up repository structure |
| 78 | + run: | |
| 79 | + # Create directories if they don't exist |
| 80 | + mkdir -p conf pool/main/p/perf-data-converter dists |
| 81 | + |
| 82 | + # Create reprepro configuration |
| 83 | + cat > conf/distributions << 'EOF' |
| 84 | + Origin: perf_data_converter |
| 85 | + Label: perf_data_converter |
| 86 | + Architectures: amd64 arm64 all |
| 87 | + Components: main |
| 88 | + Description: perf data converter APT repository |
| 89 | + SignWith: no |
| 90 | + |
| 91 | + Codename: focal |
| 92 | + Suite: focal |
| 93 | + |
| 94 | + Codename: jammy |
| 95 | + Suite: jammy |
| 96 | + |
| 97 | + Codename: noble |
| 98 | + Suite: noble |
| 99 | + EOF |
| 100 | +
|
| 101 | + - name: Move .deb files to pool |
| 102 | + run: | |
| 103 | + mv artifacts/*.deb pool/main/p/perf-data-converter/ |
| 104 | +
|
| 105 | + - name: Update repository for each suite |
| 106 | + run: | |
| 107 | + for suite in focal jammy noble; do |
| 108 | + echo "Processing suite: $suite" |
| 109 | + reprepro -b . includedeb $suite pool/main/p/perf-data-converter/*.deb |
| 110 | + done |
| 111 | +
|
| 112 | + - name: Commit and push changes |
| 113 | + run: | |
| 114 | + git config --local user.email "[email protected]" |
| 115 | + git config --local user.name "GitHub Action" |
| 116 | + git add . |
| 117 | + if git diff --staged --quiet; then |
| 118 | + echo "No changes to commit" |
| 119 | + else |
| 120 | + git commit -m "Update APT repository with new package" |
| 121 | + git push |
| 122 | + fi |
| 123 | +
|
| 124 | + test: |
| 125 | + needs: publish |
| 126 | + runs-on: ubuntu-latest |
| 127 | + strategy: |
| 128 | + matrix: |
| 129 | + distro: ['20.04', '22.04', '24.04'] |
| 130 | + arch: ['amd64', 'arm64'] |
| 131 | + steps: |
| 132 | + - name: Test package installation |
| 133 | + run: | |
| 134 | + # Map Ubuntu versions to codenames |
| 135 | + case "${{ matrix.distro }}" in |
| 136 | + "20.04") CODENAME="focal" ;; |
| 137 | + "22.04") CODENAME="jammy" ;; |
| 138 | + "24.04") CODENAME="noble" ;; |
| 139 | + *) echo "Unknown distro version"; exit 1 ;; |
| 140 | + esac |
| 141 | +
|
| 142 | + # Create and run Docker container |
| 143 | + docker run --rm --platform linux/${{ matrix.arch }} ubuntu:${{ matrix.distro }} bash -c " |
| 144 | + set -e |
| 145 | + apt-get update |
| 146 | + apt-get install -y apt-transport-https gnupg curl |
| 147 | +
|
| 148 | + # Add our APT repository |
| 149 | + echo 'deb [trusted=yes] https://redis-performance.github.io/perf_data_converter focal main' > /etc/apt/sources.list.d/perf_data_converter.list |
| 150 | + echo 'deb [trusted=yes] https://redis-performance.github.io/perf_data_converter jammy main' >> /etc/apt/sources.list.d/perf_data_converter.list |
| 151 | + echo 'deb [trusted=yes] https://redis-performance.github.io/perf_data_converter noble main' >> /etc/apt/sources.list.d/perf_data_converter.list |
| 152 | +
|
| 153 | + # Update package list and install our package |
| 154 | + apt-get update |
| 155 | + apt-get install -y perf-data-converter |
| 156 | +
|
| 157 | + # Test that the binary works |
| 158 | + perf-data-converter --help || /usr/local/bin/perf_to_profile --help |
| 159 | +
|
| 160 | + echo 'Package installation and basic functionality test passed!' |
| 161 | + " |
0 commit comments