diff options
Diffstat (limited to '.github/workflows/release.yml')
| -rw-r--r-- | .github/workflows/release.yml | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dfc3e88..63728cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,9 +9,43 @@ permissions: contents: write jobs: + extract-version: + name: Extract Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.version }} + version_valid: ${{ steps.validate_version.outputs.valid }} + steps: + - uses: actions/checkout@v4 + + - name: Get version from Cargo.toml + id: get_version + run: | + VERSION=$(grep '^version =' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/') + echo "Extracted version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Validate SemVer + id: validate_version + run: | + VERSION=${{ steps.get_version.outputs.version }} + # Comprehensive SemVer validation regex + # Supports: MAJOR.MINOR.PATCH-PRERELEASE+BUILD + # Where PRERELEASE can be: alpha, beta, rc.1, etc. + # Where BUILD can be: build.123, sha.abc123, etc. + if [[ ! $VERSION =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$ ]]; then + echo "Error: Version '$VERSION' is not a valid SemVer string" + echo "valid=false" >> $GITHUB_OUTPUT + exit 1 + else + echo "Version '$VERSION' is valid SemVer" + echo "valid=true" >> $GITHUB_OUTPUT + fi + build-windows: name: Build Windows runs-on: windows-latest + needs: extract-version strategy: matrix: target: @@ -32,17 +66,18 @@ jobs: run: | mkdir artifacts $arch = "${{ matrix.target }}".Split('-')[0] - copy "target\${{ matrix.target }}\release\mikusays.exe" "artifacts\mikusays-windows-$arch.exe" + $version = "${{ needs.extract-version.outputs.version }}" + copy "target\${{ matrix.target }}\release\mikusays.exe" "artifacts\mikusays-windows-$arch-$version.exe" - name: Upload artifact uses: actions/upload-artifact@v4 with: name: mikusays-windows-${{ matrix.target }} path: artifacts\* - build-linux: name: Build Linux runs-on: ubuntu-latest + needs: extract-version strategy: matrix: include: @@ -79,7 +114,8 @@ jobs: - name: Prepare artifact run: | mkdir -p artifacts - cp target/${{ matrix.target }}/release/mikusays artifacts/mikusays-linux-${{ matrix.arch }} + version="${{ needs.extract-version.outputs.version }}" + cp target/${{ matrix.target }}/release/mikusays artifacts/mikusays-linux-${{ matrix.arch }}-$version chmod +x artifacts/mikusays-linux-${{ matrix.arch }} - name: Upload artifact @@ -87,10 +123,10 @@ jobs: with: name: mikusays-linux-${{ matrix.arch }} path: artifacts/* - build-macos: name: Build macOS runs-on: macos-latest + needs: extract-version strategy: matrix: include: @@ -115,7 +151,8 @@ jobs: - name: Prepare artifact run: | mkdir -p artifacts - cp target/${{ matrix.target }}/release/mikusays artifacts/mikusays-macos-${{ matrix.arch }} + version="${{ needs.extract-version.outputs.version }}" + cp target/${{ matrix.target }}/release/mikusays artifacts/mikusays-macos-${{ matrix.arch }}-$version chmod +x artifacts/mikusays-macos-${{ matrix.arch }} - name: Upload artifact @@ -127,8 +164,8 @@ jobs: create-release: name: Create Release runs-on: ubuntu-latest - needs: [build-windows, build-linux, build-macos] - if: startsWith(github.ref, 'refs/tags/v') + needs: [extract-version, build-windows, build-linux, build-macos] + if: startsWith(github.ref, 'refs/tags/v') && needs.extract-version.outputs.version_valid == 'true' steps: - uses: actions/checkout@v4 @@ -144,7 +181,7 @@ jobs: - name: Create Release uses: softprops/action-gh-release@v1 with: - files: artifacts/* + files: artifacts/mikusays-* draft: false prerelease: false generate_release_notes: true @@ -152,15 +189,15 @@ jobs: ## Downloads ### Windows - - **x64**: `mikusays-windows-x86_64.exe` - - **ARM64**: `mikusays-windows-aarch64.exe` + - **x64**: `mikusays-windows-x86_64-${{ needs.extract-version.outputs.version }}.exe` + - **ARM64**: `mikusays-windows-aarch64-${{ needs.extract-version.outputs.version }}.exe` ### Windows Installer - **Any**: `mikusays-windows-inst-any.exe` ### Linux (binary) - - **x64**: `mikusays-linux-x64` - - **ARM64**: `mikusays-linux-arm64` + - **x64**: `mikusays-linux-x64-${{ needs.extract-version.outputs.version }}` + - **ARM64**: `mikusays-linux-arm64-${{ needs.extract-version.outputs.version }}` ### Debian Package - **x64 Debian Package**: `mikusays-debian-x64.deb` @@ -174,8 +211,8 @@ jobs: Information on how to add it available here https://apt.xxanqw.pp.ua ### macOS - - **Intel (x64)**: `mikusays-macos-x64` - - **Apple Silicon (ARM64)**: `mikusays-macos-arm64` + - **Intel (x64)**: `mikusays-macos-x64-${{ needs.extract-version.outputs.version }}` + - **Apple Silicon (ARM64)**: `mikusays-macos-arm64-${{ needs.extract-version.outputs.version }}` ## Usage ```bash |
