diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 95c6304..f73aedd 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -1,24 +1,21 @@ name: Docker Publish on: - release: - types: - - published workflow_dispatch: - inputs: - isLatest: - description: "Add latest tag" - default: "true" - required: true + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' + jobs: publish-docker: name: publish-docker runs-on: ubuntu-latest - permissions: - id-token: write # Needed for auth with Deno Deploy - contents: read # Needed to clone the repository - steps: - uses: actions/checkout@v4 @@ -28,40 +25,30 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: subquerynetwork/subql-ai-app + - name: Login to DockerHub uses: docker/login-action@v3 with: username: subquerynetwork password: ${{ secrets.SQ_DOCKERHUB_TOKEN }} - # Read the version from deno.json - - name: Extract version - id: extract_version - run: | - version=$(cat deno.json | jq -r '.version') - echo "AI_APP_VERSION=$version" >> $GITHUB_ENV - - - name: Build and push - if: github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'false' - uses: docker/build-push-action@v5 - with: - context: . - push: true - platforms: arm64,amd64 - file: ./Dockerfile - tags: subquerynetwork/subql-ai-app:v${{ env.AI_APP_VERSION }} - build-args: RELEASE_VERSION=${{ env.AI_APP_VERSION }} + - name: Update package deno.json + run: jq --arg version "${{ steps.meta.outputs.version }}" '.version = $version' deno.json > tmp.json && mv tmp.json deno.json - name: Build and push - if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.isLatest == 'true') uses: docker/build-push-action@v5 with: context: . - push: true platforms: arm64,amd64 file: ./Dockerfile - tags: subquerynetwork/subql-ai-app:v${{ env.AI_APP_VERSION }},subquerynetwork/subql-ai-app:latest - build-args: RELEASE_VERSION=${{ env.AI_APP_VERSION }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..54743d0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +# .github/workflows/publish.yml + +name: Publish + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # The OIDC ID token is used for authentication with JSR. + steps: + - uses: actions/checkout@v4 + - run: deno run -A jsr:@david/publish-on-tag@0.1.4 --allow-slow-types \ No newline at end of file diff --git a/deno.json b/deno.json index b344329..cdc8751 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@subql/ai-app-framework", - "version": "1.0.0-16", + "version": "0.0.0", "exports": { "./cli": "./src/index.ts", ".": "./src/mod.ts"