Skip to content

Commit

Permalink
Merge pull request #9 from i-dot-ai/EN-623/ci_rework
Browse files Browse the repository at this point in the history
rework ci to avoid trusted publisher limitations
  • Loading branch information
RyanWhite25 authored Oct 16, 2024
2 parents e18442e + 7bf6736 commit 99b8f1d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 55 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
---
name: Publish
run-name: Publish ${{ inputs.tag }} to PyPI
run-name: Publish ${{ github.event.release.tag_name }} to PyPI

on:
workflow_call:
inputs:
stage:
type: string
required: true
tag:
type: string
required: true
release:
types: [released]

jobs:
build-and-publish:
Expand All @@ -37,23 +31,16 @@ jobs:
poetry install
- name: Bump version number
run: poetry version ${{ inputs.tag }}
run: poetry version ${{ github.event.release.tag_name }}

- name: Build package
run: poetry build

- name: Publish to test pypi
if: inputs.stage == 'test'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: 'https://test.pypi.org/legacy/'

- name: Publish to prod pypi
if: inputs.stage == 'prod'
uses: pypa/gh-action-pypi-publish@release/v1

determine-success:
if: inputs.stage == 'prod' && always()
if: always()
needs:
- build-and-publish
runs-on: ubuntu-latest
Expand All @@ -69,14 +56,14 @@ jobs:
fi
notify-slack:
if: inputs.stage == 'prod' && always()
if: always()
uses: i-dot-ai/i-dot-ai-core-github-actions/.github/workflows/slack-notify.yml@main
needs:
- build-and-publish
- determine-success
with:
WORKFLOW_PASSED: ${{ needs.determine-success.outputs.success == 'true' }}
SUCCESS_PAYLOAD: "{\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":airplane: ${{ github.repository }} - Successfully deployed ${{ inputs.tag }} :large_green_circle:\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Package published to PyPI successfully\"}}]}"
FAILURE_PAYLOAD: "{\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":x: ${{ github.repository }} - Failed to deploy ${{ inputs.tag }} :x:\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Failed to publish package to PyPI\"}}]}"
SUCCESS_PAYLOAD: "{\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":airplane: ${{ github.repository }} - Successfully deployed ${{ github.event.release.tag_name }}:large_green_circle:\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Package published to PyPI successfully\"}}]}"
FAILURE_PAYLOAD: "{\"blocks\":[{\"type\":\"header\",\"text\":{\"type\":\"plain_text\",\"text\":\":x: ${{ github.repository }} - Failed to deploy ${{ github.event.release.tag_name }} :x:\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"Failed to publish package to PyPI\"}}]}"
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
15 changes: 0 additions & 15 deletions .github/workflows/release.yml

This file was deleted.

35 changes: 16 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
name: Run tests
on:
push:
workflow_call:

jobs:
test-code:
strategy:
fail-fast: false
matrix:
os: ["macos-latest"]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
test:
runs-on: "macos-latest"
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Setup Python ${{ matrix.python-version }}
- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: "3.12"
cache: "poetry"

- name: Install dependencies
run: |
poetry env use python
poetry env use "3.12"
poetry install
- name: Run Checks
run: |
bash scripts/test.sh --ci
test-publish:
if: github.event.ref_name == github.event.repository.default_branch
needs:
- test-code
uses: i-dot-ai/cruft-iai/.github/workflows/publish.yml@master
with:
stage: test
tag: "0.0.0"
- name: Bump version number
run: poetry version 0.0.0

- name: Build package
run: poetry build

- name: Publish to test pypi
if: github.ref_name == github.event.repository.default_branch
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: 'https://test.pypi.org/legacy/'

0 comments on commit 99b8f1d

Please sign in to comment.