From 88904401db016d6e4266f3f66b9a0a4ef572471d Mon Sep 17 00:00:00 2001 From: Yuri Volkov <0@mcornholio.ru> Date: Thu, 22 Aug 2024 22:16:47 +0200 Subject: [PATCH] Publishing crates on release (#38) --- .github/workflows/docker_publish.yml | 34 ---------------- .github/workflows/publish.yml | 59 ++++++++++++++++++++++++++++ Cargo.lock | 4 +- Cargo.toml | 2 +- cli/Cargo.toml | 2 +- 5 files changed, 63 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/docker_publish.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml deleted file mode 100644 index fc99c16..0000000 --- a/.github/workflows/docker_publish.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish Docker image - -on: - push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - - name: Log in to Docker Hub - uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0 - with: - images: paritytech/prdoc - - - name: Build and push Docker image - uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 #v4.1.1 - with: - file: Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..81935a5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,59 @@ +name: Publish Docker image and crates + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # v4.6.0 + with: + images: paritytech/prdoc + + - name: Build and push Docker image + uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 #v4.1.1 + with: + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + publish_crates: + name: Publish crates to crates.io + runs-on: ubuntu-latest + container: + image: docker.io/paritytech/ci-unified:bullseye-1.79.0-2024-06-10-v202408151233 + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: set version + # removing leading "v" from tag name + run: cargo set-version "$(echo "${{ github.ref_name }}" | sed -e 's/^v//')" + + - name: Build and publish prdoclib + run: cargo publish -p prdoclib --token "${CRATESIO_TOKEN}" + env: + CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }} + + - name: Build and publish prdoc + # `set-version` will change Cargo.toml in `cli` package as it depends on `prdoclib` + # thus, we need --allow-dirty, to include uncommitted changes; + run: cargo publish --allow-dirty -p prdoc --token "${CRATESIO_TOKEN}" + env: + CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index 465c70b..578a33c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -605,7 +605,7 @@ checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "prdoc" -version = "0.0.8" +version = "0.0.0-updated-from-ci" dependencies = [ "assert_cmd", "clap", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "prdoclib" -version = "0.0.8" +version = "0.0.0-updated-from-ci" dependencies = [ "exitcode", "log", diff --git a/Cargo.toml b/Cargo.toml index 97718fc..875551c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.0.8" +version = "0.0.0-updated-from-ci" authors = ["chevdor ", "Wilfried Kopp ", "Yuri Volkov <0@mcornholio.ru>"] edition = "2021" homepage = "https://github.com/paritytech/prdoc" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 87eca77..16ca672 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -12,7 +12,7 @@ license.workspace = true readme = "README.md" [dependencies] -prdoclib = { path = "../prdoclib", version = "0.0.8-beta" } +prdoclib = { path = "../prdoclib", version = "0.0.0-updated-from-ci" } log = "0.4" exitcode = "1.1"