|
| 1 | +--- |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + tags: |
| 10 | + - "v*" |
| 11 | + |
| 12 | +# contents: read covers all jobs. A future release-publishing job will need |
| 13 | +# contents: write — set it at the job level there rather than widening here. |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v6 |
| 22 | + |
| 23 | + - name: Install Rust stable |
| 24 | + uses: dtolnay/rust-toolchain@stable |
| 25 | + |
| 26 | + - name: Cache cargo registry |
| 27 | + uses: actions/cache@v5 |
| 28 | + with: |
| 29 | + path: | |
| 30 | + ~/.cargo/registry/index/ |
| 31 | + ~/.cargo/registry/cache/ |
| 32 | + ~/.cargo/git/db/ |
| 33 | + target/ |
| 34 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-cargo- |
| 37 | +
|
| 38 | + - name: Check formatting |
| 39 | + run: cargo fmt --all -- --check |
| 40 | + |
| 41 | + - name: Clippy |
| 42 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 43 | + |
| 44 | + - name: Run tests |
| 45 | + run: cargo test --all |
| 46 | + |
| 47 | + build-release: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: test |
| 50 | + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Install Rust stable + musl target |
| 55 | + uses: dtolnay/rust-toolchain@stable |
| 56 | + with: |
| 57 | + targets: x86_64-unknown-linux-musl |
| 58 | + |
| 59 | + - name: Install musl tools |
| 60 | + run: sudo apt-get install -y musl-tools |
| 61 | + |
| 62 | + - name: Build static release binary |
| 63 | + run: cargo build --release --target x86_64-unknown-linux-musl |
| 64 | + |
| 65 | + - name: Upload binary artifact |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: fix-perms-x86_64-musl |
| 69 | + path: target/x86_64-unknown-linux-musl/release/fix-perms |
| 70 | + if-no-files-found: error |
| 71 | + |
| 72 | + package: |
| 73 | + runs-on: ubuntu-latest |
| 74 | + needs: build-release |
| 75 | + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v6 |
| 78 | + |
| 79 | + - name: Download binary artifact |
| 80 | + uses: actions/download-artifact@v7 |
| 81 | + with: |
| 82 | + name: fix-perms-x86_64-musl |
| 83 | + path: target/x86_64-unknown-linux-musl/release/ |
| 84 | + |
| 85 | + - name: Restore binary permissions |
| 86 | + run: chmod +x target/x86_64-unknown-linux-musl/release/fix-perms |
| 87 | + |
| 88 | + - name: Derive package version |
| 89 | + id: version |
| 90 | + run: | |
| 91 | + # Strip the leading 'v' from tag names (v1.2.3 → 1.2.3). |
| 92 | + # Both dpkg and rpm reject version strings that start with 'v'. |
| 93 | + ref="${GITHUB_REF_NAME}" |
| 94 | + echo "value=${ref#v}" >> "$GITHUB_OUTPUT" |
| 95 | +
|
| 96 | + - name: Install nfpm |
| 97 | + run: | |
| 98 | + echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' \ |
| 99 | + | sudo tee /etc/apt/sources.list.d/goreleaser.list |
| 100 | + sudo apt-get update |
| 101 | + sudo apt-get install -y nfpm |
| 102 | +
|
| 103 | + - name: Build .deb package |
| 104 | + run: nfpm package --config nfpm.yaml --packager deb --target dist/ |
| 105 | + env: |
| 106 | + VERSION: ${{ steps.version.outputs.value }} |
| 107 | + |
| 108 | + - name: Build .rpm package |
| 109 | + run: nfpm package --config nfpm.yaml --packager rpm --target dist/ |
| 110 | + env: |
| 111 | + VERSION: ${{ steps.version.outputs.value }} |
| 112 | + |
| 113 | + - name: Upload packages |
| 114 | + uses: actions/upload-artifact@v7 |
| 115 | + with: |
| 116 | + name: ignity-extensions-packages |
| 117 | + path: dist/ |
| 118 | + if-no-files-found: error |
0 commit comments