|
| 1 | +# |
| 2 | +# Manual release workflow - triggered via GitHub UI to create tagged releases |
| 3 | +# |
| 4 | +name: Release |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: 'Version to release (e.g., v0.1.0)' |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + prerelease: |
| 14 | + description: 'Mark as pre-release' |
| 15 | + required: false |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + |
| 19 | +jobs: |
| 20 | + create-tag: |
| 21 | + name: Create release tag |
| 22 | + runs-on: ubuntu-latest |
| 23 | + permissions: |
| 24 | + contents: write |
| 25 | + outputs: |
| 26 | + tag_created: ${{ steps.tag.outputs.created }} |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Validate version format |
| 33 | + run: | |
| 34 | + if [[ ! "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then |
| 35 | + echo "Error: Version must match format v0.0.0 or v0.0.0-suffix" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Check if tag exists |
| 40 | + id: check |
| 41 | + run: | |
| 42 | + if git rev-parse "${{ inputs.version }}" >/dev/null 2>&1; then |
| 43 | + echo "Tag ${{ inputs.version }} already exists" |
| 44 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 45 | + else |
| 46 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Create and push tag |
| 50 | + id: tag |
| 51 | + if: steps.check.outputs.exists != 'true' |
| 52 | + run: | |
| 53 | + git config user.name "github-actions[bot]" |
| 54 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 55 | + git tag -a "${{ inputs.version }}" -m "Release ${{ inputs.version }}" |
| 56 | + git push origin "${{ inputs.version }}" |
| 57 | + echo "created=true" >> $GITHUB_OUTPUT |
| 58 | +
|
| 59 | + build: |
| 60 | + name: Build (${{ matrix.duckdb_arch }}) |
| 61 | + needs: create-tag |
| 62 | + runs-on: ${{ matrix.os }} |
| 63 | + strategy: |
| 64 | + fail-fast: false |
| 65 | + matrix: |
| 66 | + include: |
| 67 | + - os: ubuntu-latest |
| 68 | + duckdb_arch: linux_amd64 |
| 69 | + rust_target: x86_64-unknown-linux-gnu |
| 70 | + - os: macos-13 |
| 71 | + duckdb_arch: osx_amd64 |
| 72 | + rust_target: x86_64-apple-darwin |
| 73 | + - os: macos-14 |
| 74 | + duckdb_arch: osx_arm64 |
| 75 | + rust_target: aarch64-apple-darwin |
| 76 | + |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v4 |
| 79 | + with: |
| 80 | + submodules: recursive |
| 81 | + fetch-depth: 0 |
| 82 | + |
| 83 | + - name: Install Rust |
| 84 | + uses: dtolnay/rust-action@stable |
| 85 | + with: |
| 86 | + targets: ${{ matrix.rust_target }} |
| 87 | + |
| 88 | + - name: Build Rust library |
| 89 | + run: | |
| 90 | + cd yardstick-rs |
| 91 | + cargo build --release |
| 92 | +
|
| 93 | + - name: Build extension |
| 94 | + run: make release |
| 95 | + |
| 96 | + - name: Test extension |
| 97 | + run: make test |
| 98 | + |
| 99 | + - name: Upload artifact |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: yardstick-${{ matrix.duckdb_arch }} |
| 103 | + path: build/release/extension/yardstick/yardstick.duckdb_extension |
| 104 | + |
| 105 | + release: |
| 106 | + name: Create GitHub Release |
| 107 | + needs: [create-tag, build] |
| 108 | + runs-on: ubuntu-latest |
| 109 | + permissions: |
| 110 | + contents: write |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@v4 |
| 113 | + |
| 114 | + - name: Download all artifacts |
| 115 | + uses: actions/download-artifact@v4 |
| 116 | + with: |
| 117 | + path: artifacts |
| 118 | + |
| 119 | + - name: Prepare release assets |
| 120 | + run: | |
| 121 | + mkdir -p release_assets |
| 122 | + for dir in artifacts/*/; do |
| 123 | + platform=$(basename "$dir") |
| 124 | + for ext in "$dir"*.duckdb_extension*; do |
| 125 | + [ -f "$ext" ] || continue |
| 126 | + filename=$(basename "$ext") |
| 127 | + newname="${filename/.duckdb_extension/-${platform}.duckdb_extension}" |
| 128 | + cp "$ext" "release_assets/$newname" |
| 129 | + done |
| 130 | + done |
| 131 | + ls -la release_assets/ |
| 132 | +
|
| 133 | + - name: Create release |
| 134 | + uses: softprops/action-gh-release@v2 |
| 135 | + with: |
| 136 | + tag_name: ${{ inputs.version }} |
| 137 | + name: ${{ inputs.version }} |
| 138 | + prerelease: ${{ inputs.prerelease }} |
| 139 | + generate_release_notes: true |
| 140 | + files: release_assets/* |
0 commit comments