Update models for nomasx1 #82
This file contains hidden or 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
| # Build and deploy Docker images to GitHub Container Registry | |
| name: Build and Publish Multi-Architecture Docker Images | |
| on: | |
| pull_request: | |
| types: | |
| - closed # Only trigger the workflow when the pull request is closed (merged) | |
| branches: | |
| - main | |
| # Define the permissions for the workflow | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| # Job to create a tag and use that for all images | |
| create-version-tag: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Fetch the full history and all tags | |
| - name: Extract branch name | |
| id: get_branch_name | |
| run: | | |
| # Get the branch that was merged into main (source branch) | |
| BRANCH_NAME="${{ github.event.pull_request.head.ref }}" | |
| echo "Branch name: $BRANCH_NAME" | |
| echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" | |
| - name: Extract major version from branch name | |
| id: get_major_version | |
| run: | | |
| # Assuming branch names like 'v1.x', 'v2.x', etc. | |
| if [[ "${{ steps.get_branch_name.outputs.branch_name }}" =~ ^v([0-9]+)\. ]]; then | |
| MAJOR_VERSION="${BASH_REMATCH[1]}" | |
| echo "Major version: $MAJOR_VERSION" | |
| echo "major_version=$MAJOR_VERSION" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Could not determine major version from branch name." | |
| exit 1 | |
| fi | |
| - name: Extract current version | |
| id: get_version | |
| run: | | |
| # Get the latest tag for the major version (e.g., v1.0.x) | |
| LATEST_TAG=$(git tag --list "${{ steps.get_major_version.outputs.major_version }}.*" --sort=-v:refname | head -n 1) | |
| echo "Latest tag for major version: $LATEST_TAG" | |
| if [ -z "$LATEST_TAG" ]; then | |
| # If no tag exists, start from vMAJOR.0.0 | |
| NEW_TAG="${{ steps.get_major_version.outputs.major_version }}.0.0" | |
| else | |
| # Extract the minor and patch versions | |
| MINOR_VERSION=$(echo "$LATEST_TAG" | awk -F. '{print $2}') | |
| PATCH_VERSION=$(echo "$LATEST_TAG" | awk -F. '{print $3}') | |
| if [ "$PATCH_VERSION" -ge 99 ]; then | |
| # If patch reaches 100, reset patch to 0 and increment minor | |
| NEW_MINOR_VERSION=$((MINOR_VERSION + 1)) | |
| NEW_TAG="${{ steps.get_major_version.outputs.major_version }}.$NEW_MINOR_VERSION.0" | |
| else | |
| # Otherwise, just increment the patch | |
| NEW_PATCH_VERSION=$((PATCH_VERSION + 1)) | |
| NEW_TAG="${{ steps.get_major_version.outputs.major_version }}.$MINOR_VERSION.$NEW_PATCH_VERSION" | |
| fi | |
| fi | |
| echo "New tag: $NEW_TAG" | |
| echo "version=$NEW_TAG" >> $GITHUB_OUTPUT | |
| # Push the new tag to the repository | |
| - name: Create and push new tag | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git tag ${{ steps.get_version.outputs.version }} # Create a new tag | |
| git push origin ${{ steps.get_version.outputs.version }} # Push the tag to the remote repository | |
| # Build framework image | |
| build-framework: | |
| needs: create-version-tag | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Update package.json to use NPM version of liberty-core | |
| run: npm pkg set dependencies.@nomana-it/liberty-core=latest | |
| working-directory: frontend | |
| - name: Install frontend dependencies | |
| run: npm install | |
| working-directory: frontend | |
| - name: Build frontend | |
| run: npm run build | |
| working-directory: frontend | |
| - name: Install Setup dependencies | |
| run: npm install | |
| working-directory: setup | |
| - name: Build setup | |
| run: npm run build | |
| working-directory: setup | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: pip install --upgrade setuptools wheel build | |
| - name: Build Python package (sdist & wheel) | |
| run: | | |
| python -m build --sdist && python -m build --wheel | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| install: true | |
| - name: Login to GitHub Packages | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.create-version-tag.outputs.version }} | |
| name: Release ${{ needs.create-version-tag.outputs.version }} | |
| body: | | |
| ## Changes in this release | |
| - Automatic release of Python package version ${{ needs.create-version-tag.outputs.version }}. | |
| draft: false | |
| prerelease: false | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install Twine | |
| run: pip install --upgrade twine | |
| - name: Upload to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload dist/* | |
| - name: Wait for PyPI | |
| run: sleep 30s | |
| - name: Build and push framework image (arm64 and amd64) | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile | |
| push: true | |
| platforms: linux/arm64, linux/amd64 | |
| tags: ghcr.io/${{ github.repository_owner }}/liberty-framework:${{ needs.create-version-tag.outputs.version }}, | |
| ghcr.io/${{ github.repository_owner }}/liberty-framework:latest | |