From b493871dc521966a7a14ebc147a9fa332658d198 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Wed, 10 Jan 2024 14:37:05 +0100 Subject: [PATCH] Test package version from Git tag --- .github/workflows/python.yml | 49 ++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f9197df..b7cbd2a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -19,8 +19,22 @@ permissions: contents: read jobs: + set-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.genversion.version }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: "0" + - name: Generate package version from Git tag + id: genversion + run: | + echo "version=$(git describe --tags --always --match=v* | sed 's/^v//' | cut -d- -f1,2)" >> "$GITHUB_OUTPUT" + linux: runs-on: ubuntu-latest + needs: set-version strategy: matrix: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] @@ -29,6 +43,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.10' + - uses: taiki-e/cache-cargo-install-action@v1 + with: + tool: cargo-edit + - name: Set package version + env: + VERSION: ${{ needs.set-version.outputs.version }} + run: | + cargo set-version "${VERSION}" - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -67,6 +89,7 @@ jobs: windows: runs-on: windows-latest + needs: set-version strategy: matrix: target: [x64, x86] @@ -76,6 +99,14 @@ jobs: with: python-version: '3.10' architecture: ${{ matrix.target }} + - uses: taiki-e/cache-cargo-install-action@v1 + with: + tool: cargo-edit + - name: Set package version + env: + VERSION: ${{ needs.set-version.outputs.version }} + run: | + cargo set-version "${VERSION}" - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -98,6 +129,7 @@ jobs: macos: runs-on: macos-latest + needs: set-version strategy: matrix: target: [x86_64, aarch64] @@ -106,6 +138,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.10' + - uses: taiki-e/cache-cargo-install-action@v1 + with: + tool: cargo-edit + - name: Set package version + env: + VERSION: ${{ needs.set-version.outputs.version }} + run: | + cargo set-version "${VERSION}" - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -128,8 +168,17 @@ jobs: sdist: runs-on: ubuntu-latest + needs: set-version steps: - uses: actions/checkout@v4 + - uses: taiki-e/cache-cargo-install-action@v1 + with: + tool: cargo-edit + - name: Set package version + env: + VERSION: ${{ needs.set-version.outputs.version }} + run: | + cargo set-version "${VERSION}" - name: Build sdist uses: PyO3/maturin-action@v1 with: diff --git a/Cargo.toml b/Cargo.toml index bf12365..4bc3190 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reclass-rs" -version = "0.1.1" +version = "0.0.0" edition = "2021" license = "BSD-3-Clause" authors = ["VSHN AG "]