Skip to content

Merge pull request #247 from CoinFabrik/doc/action-and-extension-readme #34

Merge pull request #247 from CoinFabrik/doc/action-and-extension-readme

Merge pull request #247 from CoinFabrik/doc/action-and-extension-readme #34

Workflow file for this run

name: Release
on:
push:
branches:
- main
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
with:
fetch-depth: 0
- name: Filter Paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
scout_audit:
- 'apps/cargo-scout-audit/**'
base: main
list-files: none
initial-fetch-depth: 0
crates-release:
name: Release to crates.io
needs: filter-paths
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- 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: Login to crates.io
run: echo ${{ secrets.CRATES_TOKEN }} | cargo login
- name: Publish Scout Audit
if: ${{ needs.filter-paths.outputs.scout-audit == 'true' }}
run: python scripts/publish-to-crates-io.py --crate-path apps/cargo-scout-audit
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
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: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- 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: true
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