diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d39302a..e0d1cb6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -65,18 +65,23 @@ jobs: uses: cargo-bins/cargo-binstall@main - name: Install wkg run: cargo binstall --force wkg + - name: Install wasm-tools + run: cargo binstall --force wasm-tools - name: Install cosign uses: sigstore/cosign-installer@v4.1.2 - - name: Get tag version - if: startsWith(github.ref, 'refs/tags/') - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Download components.tar uses: actions/download-artifact@v8 with: name: components.tar - name: Extract components run: tar -xvf components.tar -C lib + - name: Get interface version + id: interface_version + run: echo ::set-output name=VERSION::$( wasm-tools component wit lib/interface.wasm --json | jq -r '.packages[0].name' | cut -d'@' -f2 )} + - name: Get tag version + if: startsWith(github.ref, 'refs/tags/') + id: tag_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Login to GitHub Container Registry uses: docker/login-action@v4 with: @@ -84,10 +89,12 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Publish components to gchr.io + # only publish tags and pre-releases from main + if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && contains(steps.interface_version.outputs.VERSION, '-')) run: make publish env: REPOSITORY: "ghcr.io/${{ github.repository }}" - VERSION: "${{ case(github.ref == 'refs/heads/main', 'dev', steps.get_version.outputs.VERSION) }}" + VERSION: "${{ case(github.ref == 'refs/heads/main', steps.interface_version.outputs.VERSION, steps.tag_version.outputs.VERSION) }}" - name: Draft GitHub Release if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v3 diff --git a/Makefile b/Makefile index b59288b..150ffbd 100644 --- a/Makefile +++ b/Makefile @@ -69,8 +69,9 @@ endif @$(eval DESCRIPTION := $(shell head -n 3 "lib/${FILE}.md" | tail -n 1)) @$(eval REVISION := $(shell git rev-parse HEAD)$(shell git diff --quiet HEAD && echo "+dirty")) @$(eval TAG := $(patsubst v%,%,$(subst +,_,$(VERSION)))) + @$(eval IMAGE := $(if $(filter interface.wasm,$(FILE)),${REPOSITORY}:${TAG},${REPOSITORY}/${COMPONENT}:${TAG})) - @echo "::group::${FILE} -> ${REPOSITORY}/${COMPONENT}:${TAG}" + @echo "::group::${FILE} -> ${IMAGE}" @DIGEST=$$( \ wkg oci push \ --annotation "org.opencontainers.image.title=${COMPONENT}" \ @@ -79,11 +80,11 @@ endif --annotation "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}.git" \ --annotation "org.opencontainers.image.revision=${REVISION}" \ --annotation "org.opencontainers.image.licenses=Apache-2.0" \ - "${REPOSITORY}/${COMPONENT}:${TAG}" \ + "${IMAGE}" \ "lib/${FILE}" \ 2>&1 \ | tee /dev/stderr \ | grep -o 'sha256:[a-f0-9]\{64\}' \ ) ; \ - cosign sign --yes "${REPOSITORY}/${COMPONENT}:${TAG}@$${DIGEST}" + cosign sign --yes "${IMAGE}@$${DIGEST}" @echo "::endgroup::" diff --git a/components/wit/deps/componentized-http-0.0.0-0/package.wit b/components/wit/deps/componentized-http-0.1.0-dev/package.wit similarity index 98% rename from components/wit/deps/componentized-http-0.0.0-0/package.wit rename to components/wit/deps/componentized-http-0.1.0-dev/package.wit index 3cbee81..38d3bb1 100644 --- a/components/wit/deps/componentized-http-0.0.0-0/package.wit +++ b/components/wit/deps/componentized-http-0.1.0-dev/package.wit @@ -1,4 +1,4 @@ -package componentized:http@0.0.0-0; +package componentized:http@0.1.0-dev; interface client { enum method { diff --git a/components/wit/worlds.wit b/components/wit/worlds.wit index 2130a11..2f2b2f9 100644 --- a/components/wit/worlds.wit +++ b/components/wit/worlds.wit @@ -2,5 +2,5 @@ package componentized:components; world http-client { import wasi:http/client@0.3.1; - export componentized:http/client@0.0.0-0; + export componentized:http/client@0.1.0-dev; } diff --git a/wit/http.wit b/wit/http.wit index 0986c1c..5dfbcb6 100644 --- a/wit/http.wit +++ b/wit/http.wit @@ -1,4 +1,4 @@ -package componentized:http@0.0.0-0; +package componentized:http@0.1.0-dev; interface client { enum method {