build: fix cli issue #7
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
on: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: write | |
packages: write | |
jobs: | |
determine-release: | |
runs-on: ubuntu-latest | |
outputs: | |
release_needed: ${{ steps.semantic_release.outputs.release_needed }} | |
tag: ${{ steps.semantic_release.outputs.tag }} | |
env: | |
UV_TOOL_DIR: /tmp/.uv-tool | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.sha }} | |
- name: Force correct release branch | |
run: | | |
git checkout -B ${{ github.ref_name }} ${{ github.sha }} | |
- name: Install uv | |
uses: astral-sh/setup-uv@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: "backend/pyproject.toml" | |
- name: Restore uv tools | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/.uv-tools | |
key: uv-tools-${{ runner.os }}-psr-v9.11.1 | |
restore-keys: | | |
uv-tools-${{ runner.os }}-psr-v9.11.1 | |
uv-tools-${{ runner.os }} | |
- name: Install Python Semantic Release | |
run: uv tool install python-semantic-release@v9.11.1 | |
- name: Run Semantic Release | |
id: semantic_release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Checking for release and setting version in files" | |
output=$(uv tool run --from python-semantic-release semantic-release -c releaserc.toml version --commit --push --tag --changelog --no-vcs-release) | |
echo "$output" | |
version=$(uv tool run --from python-semantic-release semantic-release -c releaserc.toml --noop version --print-last-released-tag ) | |
if echo "$output" | grep -q "No release will be made"; then | |
echo "release_needed=false" >> $GITHUB_OUTPUT | |
else | |
echo "release_needed=true" >> $GITHUB_OUTPUT | |
fi | |
echo "tag=$version" >> $GITHUB_OUTPUT | |
build-frontend-docker: | |
needs: determine-release | |
if: needs.determine-release.outputs.release_needed == 'true' | |
uses: ./.github/workflows/frontend-docker.yml | |
with: | |
tag: ${{ needs.determine-release.outputs.tag }} | |
secrets: inherit | |
build-backend-docker: | |
needs: determine-release | |
if: needs.determine-release.outputs.release_needed == 'true' | |
uses: ./.github/workflows/backend-docker.yml | |
with: | |
tag: ${{ needs.determine-release.outputs.tag }} | |
secrets: inherit | |
build-frontend: | |
needs: [build-frontend-docker, determine-release] | |
if: needs.determine-release.outputs.release_needed == 'true' | |
uses: ./.github/workflows/frontend.yml | |
with: | |
tag: ${{ needs.determine-release.outputs.tag }} | |
secrets: inherit | |
github-release: | |
needs: [build-backend-docker, build-frontend, determine-release] | |
if: needs.determine-release.outputs.release_needed == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: frontend-build | |
path: dist/cloudflare/ | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: dist/cloudflare/* | |
tag_name: ${{ needs.determine-release.outputs.tag }} | |
body_path: ${{ github.workspace }}-CHANGELOG.md | |
docker-release: | |
needs: [build-backend-docker, build-frontend-docker, determine-release] | |
if: needs.determine-release.outputs.release_needed == 'true' | |
uses: ./.github/workflows/docker-release.yml | |
with: | |
tag: ${{ needs.determine-release.outputs.tag }} | |
secrets: inherit |