ci: add e2e tests (#27) #42
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
| --- | |
| name: Publish Docker image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - pyproject.toml | |
| concurrency: | |
| group: 'publish-${{ github.workflow }}' | |
| cancel-in-progress: false | |
| jobs: | |
| get-newer-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| new-version: ${{ steps.check.outputs.new_version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-tags: true | |
| fetch-depth: 0 | |
| - name: Extract version from pyproject.toml | |
| id: extract | |
| run: | | |
| VERSION=$(grep -m1 '^version\s*=' pyproject.toml | sed -E 's/version\s*=\s*"([^"]+)".*/\1/') | |
| echo "Extracted version: v$VERSION" | |
| echo "version=v$VERSION" >> $GITHUB_OUTPUT | |
| - name: Get latest tag | |
| id: latest | |
| run: | | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "none") | |
| echo "Latest tag: $LATEST_TAG" | |
| echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT | |
| - name: Check if version is new | |
| id: check | |
| run: | | |
| VERSION="${{ steps.extract.outputs.version }}" | |
| LATEST="${{ steps.latest.outputs.latest_tag }}" | |
| if [ "$VERSION" = "$LATEST" ]; then | |
| echo "No new version detected." | |
| echo "new_version=" >> $GITHUB_OUTPUT | |
| else | |
| echo "New version detected: $VERSION" | |
| echo "new_version=$VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| push_to_registry: | |
| name: Push Docker image to GitHub Packages | |
| runs-on: ubuntu-latest | |
| needs: [ get-newer-version ] | |
| if: needs.get-newer-version.outputs.new-version != '' | |
| permissions: | |
| contents: read # required for actions/checkout | |
| packages: write # required for pushing to ghcr.io | |
| id-token: write # required for signing with cosign | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v5 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| id: build-and-push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ghcr.io/sysdiglabs/sysdig-mcp-server:latest | |
| ghcr.io/sysdiglabs/sysdig-mcp-server:${{ needs.get-newer-version.outputs.new-version }} | |
| release: | |
| name: Create release at Github | |
| needs: [ get-newer-version ] | |
| if: needs.get-newer-version.outputs.new-version != '' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required for release creation | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Install Nix | |
| uses: DeterminateSystems/nix-installer-action@main | |
| - name: Install git-chglog | |
| run: nix profile install nixpkgs#git-chglog | |
| - name: Tag with version ${{ needs.get-newer-version.outputs.new-version }} | |
| run: git tag ${{ needs.get-newer-version.outputs.new-version }} | |
| - name: Generate changelog | |
| run: git-chglog -c .github/git-chglog/config.yml -o RELEASE_CHANGELOG.md $(git describe --tags $(git rev-list --tags --max-count=1)) | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ needs.get-newer-version.outputs.new-version }} | |
| tag_name: ${{ needs.get-newer-version.outputs.new-version }} | |
| prerelease: false | |
| body_path: RELEASE_CHANGELOG.md |