Skip to content

bumped version

bumped version #133

Workflow file for this run

name: PR Preview
on:
pull_request:
types: [opened, synchronize, ready_for_review]
jobs:
preview:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
# Install all dependencies from pyproject.toml
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatchling==1.27.0 hatch==1.14.0
- name: Inject full dynamic version
run: python .hooks/sync_version.py --dev
- name: Clean previous builds
run: rm -rf dist/ build/ *.egg-info
- name: Get Hatch version
id: version
run: |
VERSION=$(hatch version | cut -d+ -f1)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build package
if: steps.version_check.outputs.exists != 'true'
run: |
hatch build
- name: Publish to Test PyPI
if: steps.version_check.outputs.exists != 'true'
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Comment on PR
if: steps.version_check.outputs.exists != 'true'
uses: actions/github-script@v7
env:
VERSION: ${{ env.VERSION }}
with:
script: |
const version = process.env.VERSION;
const prNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
// Find existing bot comments
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('🚀 Preview package published!')
);
const comment = `
🚀 Preview package published!
Install with:
\`\`\`bash
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==${version}
\`\`\`
Docker image: \`socketdev/cli:pr-${prNumber}\`
`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: owner,
repo: repo,
comment_id: botComment.id,
body: comment
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: prNumber,
body: comment
});
}
- name: Verify package is available
if: steps.version_check.outputs.exists != 'true'
id: verify_package
env:
VERSION: ${{ env.VERSION }}
run: |
for i in {1..30}; do
if pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==${VERSION}; then
echo "Package ${VERSION} is now available and installable on Test PyPI"
pip uninstall -y socketsecurity
echo "success=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Attempt $i: Package not yet installable, waiting 20s... (${i}/30)"
sleep 20
done
echo "success=false" >> $GITHUB_OUTPUT
exit 1
- name: Login to Docker Hub
if: steps.verify_package.outputs.success == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build & Push Docker Preview
if: steps.verify_package.outputs.success == 'true'
uses: docker/build-push-action@v5
env:
VERSION: ${{ env.VERSION }}
with:
push: true
platforms: linux/amd64,linux/arm64
tags: |
socketdev/cli:pr-${{ github.event.pull_request.number }}
build-args: |
CLI_VERSION=${{ env.VERSION }}
PIP_INDEX_URL=https://test.pypi.org/simple
PIP_EXTRA_INDEX_URL=https://pypi.org/simple