Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 66 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ name: Release
# Required repo secrets (Settings -> Secrets and variables -> Actions):
# PYPI_API_TOKEN - PyPI account -> API tokens
# NPM_TOKEN - npmjs.com account -> Access Tokens -> Automation
# GITHUB_TOKEN (GHCR push) is provided automatically, no setup needed.
# GITHUB_TOKEN (GHCR push) is provided automatically, no setup needed. It
# can only push under this repo's own owner, so the image is
# ghcr.io/<owner>/secfoo (ghcr.io/secfoo-com/secfoo on the public repo).
#
# Every publish step skips a version that's already out, so a run that
# failed halfway can simply be re-run for the same tag.

on:
workflow_dispatch:
Expand Down Expand Up @@ -52,7 +57,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-14
- os: macos-15
name: darwin-arm64
- os: macos-15-intel
name: darwin-x64
Expand Down Expand Up @@ -96,7 +101,16 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
# The binaries are 100+ MB each and this download has failed
# transiently before ("Artifact download failed after 5 retries"),
# so give it one more attempt before failing the release.
- id: download
uses: actions/download-artifact@v4
continue-on-error: true
with:
path: artifacts
- if: steps.download.outcome == 'failure'
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifacts and compute checksums
Expand Down Expand Up @@ -126,14 +140,18 @@ jobs:
- env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*.tar.gz dist/*.whl
run: twine upload --skip-existing dist/*.tar.gz dist/*.whl

publish-npm:
name: Publish npm packages
needs: [check-version, release]
# Needs only the binaries, not the GitHub Release, so a flaky release
# upload doesn't also block npm.
needs: [check-version, build-binaries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: actions/download-artifact@v4
with:
path: artifacts
Expand All @@ -147,6 +165,19 @@ jobs:
VERSION: ${{ needs.check-version.outputs.version }}
run: |
set -euo pipefail
if [ -z "${NODE_AUTH_TOKEN:-}" ]; then
echo "::error::NPM_TOKEN secret is not set (Settings -> Secrets and variables -> Actions)."
exit 1
fi
publish() {
local dir="$1" name
name=$(node -p "require('./$dir/package.json').name")
if npm view "$name@$VERSION" version >/dev/null 2>&1; then
echo "$name@$VERSION is already on npm, skipping"
else
npm publish --access public "$dir"
fi
}
declare -A DIRS=(
[darwin-arm64]=npm/secfoo-darwin-arm64
[darwin-x64]=npm/secfoo-darwin-x64
Expand All @@ -164,10 +195,10 @@ jobs:
chmod +x "$pkgdir/bin/secfoo"
fi
npm version "$VERSION" --no-git-tag-version --prefix "$pkgdir" --allow-same-version
npm publish --access public "$pkgdir"
publish "$pkgdir"
done
npm version "$VERSION" --no-git-tag-version --prefix npm/secfoo --allow-same-version
npm publish --access public npm/secfoo
publish npm/secfoo

publish-docker:
name: Publish Docker image (GHCR)
Expand All @@ -185,12 +216,37 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image name (GHCR needs a lowercase owner)
id: image
run: echo "name=ghcr.io/$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')/secfoo" >> "$GITHUB_OUTPUT"
- name: Wait for the new version to be installable from PyPI
run: sleep 60
env:
VERSION: ${{ needs.check-version.outputs.version }}
run: |
for _ in $(seq 1 40); do
if pip download --no-deps --quiet --dest /tmp/pypi-check "secfoo==$VERSION" 2>/dev/null; then
exit 0
fi
sleep 15
done
echo "::error::secfoo==$VERSION is still not installable from PyPI after 10 minutes."
exit 1
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
build-args: |
SECFOO_VERSION=${{ needs.check-version.outputs.version }}
# The source label links the package to this repo, which is what
# lists it under the repo's "Packages" sidebar.
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.version=${{ needs.check-version.outputs.version }}
org.opencontainers.image.licenses=MIT
org.opencontainers.image.description=Secfoo CLI: context-based security assessment with your coding agent
tags: |
ghcr.io/rakfortltd/secfoo:${{ needs.check-version.outputs.version }}
ghcr.io/rakfortltd/secfoo:latest
${{ steps.image.outputs.name }}:${{ needs.check-version.outputs.version }}
${{ steps.image.outputs.name }}:latest
2 changes: 1 addition & 1 deletion src/secfoo/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.0"
__version__ = "0.3.1"
Loading