Migration CI #197
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Release | |
on: | |
pull_request: | |
branches: | |
- develop | |
- main | |
paths: | |
- "apps/cargo-scout-audit/**" | |
workflow_dispatch: | |
env: | |
PYTHONUNBUFFERED: 1 | |
REGISTRY: coinfabrik | |
IMAGE_NAME: scout | |
jobs: | |
filter-paths: | |
name: Filter modified paths by PR | |
runs-on: ubuntu-latest | |
outputs: | |
scout-audit: ${{ steps.filter.outputs.scout_audit }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Filter Paths | |
uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
scout_audit: | |
- 'apps/cargo-scout-audit/**' | |
test-release: | |
name: Test dry-run release | |
needs: filter-paths | |
runs-on: ubuntu-latest | |
outputs: | |
scout-audit: ${{ steps.scout-audit.outputs.result }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests toml | |
- name: Test Scout Audit | |
id: scout-audit | |
if: ${{ needs.filter-paths.outputs.scout-audit == 'true' }} | |
run: | | |
python scripts/publish-to-crates-io.py --crate-path apps/cargo-scout-audit --dry-run | |
echo "result=success" >> $GITHUB_OUTPUT | |
test-docker-release: | |
name: Release to Docker Hub | |
runs-on: ${{ matrix.os }} | |
needs: filter-paths | |
if: ${{ needs.filter-paths.outputs.scout-audit == 'true' }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
platform: [linux/amd64, linux/arm64] | |
permissions: | |
packages: write | |
contents: read | |
attestations: write | |
id-token: write | |
outputs: | |
docker-release: ${{ steps.test-docker-release.outputs.result }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Get scout version | |
id: scout-version | |
run: | | |
version=$(cat apps/cargo-scout-audit/Cargo.toml | grep '^version' | head -1 | awk -F '"' '{print $2}') | |
echo "Version extracted: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
- name: Set platform-specific tag prefix | |
id: set-tag-prefix | |
run: | | |
if [[ "${{ matrix.platform }}" == "linux/arm64" ]]; then | |
echo "tag_prefix=-arm64" >> $GITHUB_OUTPUT | |
else | |
echo "tag_prefix=" >> $GITHUB_OUTPUT | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: ${{ matrix.platform }} | |
cache-from: type=gha | |
cache-to: type=gha | |
push: false | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}${{ steps.set-tag-prefix.outputs.tag_prefix }}:${{ steps.scout-version.outputs.version }}, | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}${{ steps.set-tag-prefix.outputs.tag_prefix }}:latest | |
- name: Set Docker release status | |
id: test-docker-release | |
run: echo "result=success" >> $GITHUB_OUTPUT | |
comment-on-pr: | |
name: Comment on PR about release status | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
needs: [filter-paths, test-release, test-docker-release] | |
steps: | |
- name: Find existing comment | |
id: find_comment | |
uses: peter-evans/find-comment@v3 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body-includes: "🚀 Release Dry-Run Summary" | |
- name: Create or Update PR Comment | |
uses: peter-evans/create-or-update-comment@v4.0.0 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
edit-mode: replace | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
## 🚀 Release Dry-Run Summary | |
| Crate | Release Status | Dry Run Status | | |
| --- | --- | --- | | |
| [cargo-scout-audit](https://crates.io/crates/cargo-scout-audit) | ${{ needs.filter-paths.outputs.scout-audit == 'true' && '🟢 Releasing' || '🔴 Not Releasing' }} | ${{ needs.filter-paths.outputs.scout-audit == 'true' && (needs.test-release.outputs.scout-audit == 'success' && '✅ Successful' || '❌ Failed') || 'N/A' }} | | |
| [scout-docker](https://hub.docker.com/repository/docker/coinfabrik/scout/general) | ${{ needs.filter-paths.outputs.scout-audit == 'true' && '🟢 Releasing' || '🔴 Not Releasing' }} | ${{ needs.filter-paths.outputs.scout-audit == 'true' && (needs.test-docker-release.outputs.docker-release == 'success' && '✅ Successful' || '❌ Failed') || 'N/A' }} | |