From af1f3b45c5530c6dc4b98ae50a30424e87f4a35f Mon Sep 17 00:00:00 2001 From: Donkie Date: Sat, 16 Sep 2023 20:06:14 +0200 Subject: [PATCH] Add git hash to version for master builds --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8eb42ed3f..1b9f8dc5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Add git hash to version + if: github.ref == 'refs/heads/master' + run: | + current_version=$(grep -m 1 -oP 'version = "\K[^"]+' pyproject.toml) + latest_commit_hash=$(git rev-parse --short HEAD) + new_version="${current_version}+${latest_commit_hash}" + sed -i 's/version = \"${current_version}\"/version = \"${new_version}\"/' pyproject.toml + echo "Set project to version ${new_version}" + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -163,6 +172,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Add git hash to version + if: github.ref == 'refs/heads/master' + run: | + current_version=$(grep -m 1 -oP 'version = "\K[^"]+' pyproject.toml) + latest_commit_hash=$(git rev-parse --short HEAD) + new_version="${current_version}+${latest_commit_hash}" + sed -i 's/version = \"${current_version}\"/version = \"${new_version}\"/' pyproject.toml + echo "Set project to version ${new_version}" + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -195,6 +213,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Add git hash to version + if: github.ref == 'refs/heads/master' + run: | + current_version=$(grep -m 1 -oP 'version = "\K[^"]+' pyproject.toml) + latest_commit_hash=$(git rev-parse --short HEAD) + new_version="${current_version}+${latest_commit_hash}" + sed -i 's/version = \"${current_version}\"/version = \"${new_version}\"/' pyproject.toml + echo "Set project to version ${new_version}" + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -227,6 +254,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Add git hash to version + if: github.ref == 'refs/heads/master' + run: | + current_version=$(grep -m 1 -oP 'version = "\K[^"]+' pyproject.toml) + latest_commit_hash=$(git rev-parse --short HEAD) + new_version="${current_version}+${latest_commit_hash}" + sed -i 's/version = \"${current_version}\"/version = \"${new_version}\"/' pyproject.toml + echo "Set project to version ${new_version}" + - name: Set up QEMU uses: docker/setup-qemu-action@v2