deb-collections

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

cargo-deb.yaml (5056B)


      1 name: Build and Publish Debian Packages
      2 
      3 on:
      4   schedule:
      5     - cron: '37 15 * * *'
      6   workflow_dispatch:
      7 
      8 permissions:
      9   contents: write
     10   pages: write
     11   id-token: write
     12 
     13 concurrency:
     14   group: "pages"
     15   cancel-in-progress: true
     16 
     17 jobs:
     18   build:
     19     runs-on: ubuntu-latest
     20     strategy:
     21       fail-fast: false
     22       matrix:
     23         include:
     24           # - name: nushell
     25           #   type: github-release
     26           #   repo: nushell/nushell
     27           #   bin: nu
     28           #   prebuild_assets: false
     29           # - name: starship
     30           #   type: github-release
     31           #   repo: starship/starship
     32           #   bin: starship
     33           #   prebuild_assets: false
     34           # - name: zellij
     35           #   type: github-release
     36           #   repo: zellij-org/zellij
     37           #   bin: zellij
     38           #   prebuild_assets: true
     39           - name: gemini-commit-message
     40             type: git-head
     41             repo: minerva-jupiter/gemini-commit-message
     42             bin: gemini-commit-message
     43             prebuild_assets: false
     44 
     45     steps:
     46       - name: Checkout repository
     47         uses: actions/checkout@main
     48 
     49       - name: Set up Rust
     50         uses: dtolnay/rust-toolchain@stable
     51 
     52       - name: Install cargo-deb
     53         run: cargo install cargo-deb
     54 
     55       - name: Install Protoc
     56         uses: arduino/setup-protoc@v2
     57         with:
     58           repo-token: ${{ secrets.GITHUB_TOKEN }}
     59 
     60       - name: Build package (${{ matrix.name }})
     61         id: build_pkg
     62         continue-on-error: true
     63         run: |
     64           mkdir -p build_work
     65           cd build_work
     66 
     67           if [ "${{ matrix.type }}" = "github-release" ]; then
     68             LATEST_TAG=$(curl -s "https://api.github.com/repos/${{ matrix.repo }}/releases/latest" | jq -r .tag_name)
     69             git clone --depth 1 --branch "$LATEST_TAG" "https://github.com/${{ matrix.repo }}.git" source
     70           else
     71             git clone --depth 1 "https://github.com/${{ matrix.repo }}.git" source
     72           fi
     73 
     74           cd source
     75 
     76           if [ "${{ matrix.prebuild_assets }}" = "true" ]; then
     77             cargo install ${{ matrix.name }} --locked
     78             mkdir -p assets/completions assets/layouts assets/plugins assets/man
     79               ${{ matrix.bin }} setup --generate-completion bash > assets/completions/${{ matrix.bin }}.bash
     80 
     81             # zsh の補完ファイル名規約に合わせる処理
     82             # mv assets/completions/${{ matrix.bin }}.zsh assets/completions/_${{ matrix.bin }}
     83 
     84             tree assets
     85           fi
     86 
     87           cargo deb
     88 
     89           mkdir -p ../../debs
     90           cp target/debian/*.deb ../../debs/
     91 
     92       - name: Upload built deb artifact
     93         if: steps.build_pkg.outcome == 'success'
     94         uses: actions/upload-artifact@main
     95         with:
     96           name: deb-${{ matrix.name }}
     97           path: debs/*.deb
     98 
     99   deploy:
    100     needs: build
    101     if: always()
    102     runs-on: ubuntu-latest
    103     steps:
    104       - name: Checkout
    105         uses: actions/checkout@main
    106 
    107       - name: Download all deb artifacts
    108         uses: actions/download-artifact@main
    109         continue-on-error: true
    110         with:
    111           pattern: deb-*
    112           path: public
    113           merge-multiple: true
    114 
    115       - name: Check if deb files exist
    116         id: check_debs
    117         run: |
    118           mkdir -p public
    119           if [ -z "$(ls -A public/*.deb 2>/dev/null)" ]; then
    120             echo "No .deb packages were built successfully."
    121             echo "has_debs=false" >> $GITHUB_OUTPUT
    122           else
    123             echo "has_debs=true" >> $GITHUB_OUTPUT
    124           fi
    125 
    126       - name: Generate APT Index (Packages.gz & Release)
    127         if: steps.check_debs.outputs.has_debs == 'true'
    128         run: |
    129           cd public
    130           dpkg-scanpackages . /dev/null > Packages
    131           gzip -9c Packages > Packages.gz
    132 
    133           DATE=$(date -u -R)
    134           MD5=$(md5sum Packages | awk '{print $1}')
    135           SHA256=$(sha256sum Packages | awk '{print $1}')
    136           SIZE=$(stat -c%s Packages)
    137 
    138           MD5_GZ=$(md5sum Packages.gz | awk '{print $1}')
    139           SHA256_GZ=$(sha256sum Packages.gz | awk '{print $1}')
    140           SIZE_GZ=$(stat -c%s Packages.gz)
    141 
    142           cat <<EOF > Release
    143           Origin: deb-collections
    144           Label: deb-collections
    145           Suite: stable
    146           Codename: stable
    147           Date: ${DATE}
    148           Architectures: amd64
    149           Components: main
    150           Description: Personal APT Repository
    151           MD5Sum:
    152            ${MD5} ${SIZE} Packages
    153            ${MD5_GZ} ${SIZE_GZ} Packages.gz
    154           SHA256:
    155            ${SHA256} ${SIZE} Packages
    156            ${SHA256_GZ} ${SIZE_GZ} Packages.gz
    157           EOF
    158 
    159       - name: Setup Pages
    160         if: steps.check_debs.outputs.has_debs == 'true'
    161         uses: actions/configure-pages@main
    162 
    163       - name: Upload artifact for GitHub Pages
    164         if: steps.check_debs.outputs.has_debs == 'true'
    165         uses: actions/upload-pages-artifact@main
    166         with:
    167           path: public
    168 
    169       - name: Deploy to GitHub Pages
    170         if: steps.check_debs.outputs.has_debs == 'true'
    171         id: deployment
    172         uses: actions/deploy-pages@main