|
| 1 | +name: release sqlite-js |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + name: build for ${{ matrix.name }}-${{ matrix.arch }} |
| 14 | + timeout-minutes: 20 |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: ubuntu-latest |
| 20 | + arch: x86_64 |
| 21 | + name: linux |
| 22 | + - os: ubuntu-latest #LinuxARM64 |
| 23 | + arch: arm64 |
| 24 | + name: linux |
| 25 | + - os: macos-latest |
| 26 | + arch: uni |
| 27 | + name: macos |
| 28 | + - os: windows-latest |
| 29 | + arch: x86_64 |
| 30 | + name: windows |
| 31 | + |
| 32 | + defaults: |
| 33 | + run: |
| 34 | + shell: bash |
| 35 | + env: |
| 36 | + MAKEFLAGS: -j 8 |
| 37 | + |
| 38 | + steps: |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + - name: windows install sqlite3 |
| 43 | + if: matrix.os == 'windows-latest' |
| 44 | + run: choco install sqlite -y |
| 45 | + |
| 46 | + - name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION |
| 47 | + if: matrix.os == 'macos-latest' |
| 48 | + run: brew link sqlite --force |
| 49 | + |
| 50 | + - name: build sqlite-js |
| 51 | + run: make |
| 52 | + |
| 53 | + - name: test sqlite-js |
| 54 | + run: make test |
| 55 | + |
| 56 | + |
| 57 | + with: |
| 58 | + name: js-${{ matrix.name }}-${{ matrix.arch }} |
| 59 | + path: dist/js.* |
| 60 | + if-no-files-found: error |
| 61 | + |
| 62 | + release: |
| 63 | + runs-on: ubuntu-latest |
| 64 | + name: release |
| 65 | + needs: build |
| 66 | + |
| 67 | + env: |
| 68 | + GH_TOKEN: ${{ github.token }} |
| 69 | + |
| 70 | + steps: |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | + with: |
| 76 | + path: artifacts |
| 77 | + |
| 78 | + - name: generate release tag name |
| 79 | + id: tag |
| 80 | + run: | |
| 81 | + # get the current year and month |
| 82 | + YEAR=$(date +"%Y") |
| 83 | + MONTH=$(date +"%m") |
| 84 | +
|
| 85 | + # calculate the first value (year difference from 2025) |
| 86 | + FIRST=$((YEAR - 2024)) # 2025 is 1, 2026 is 2, etc. |
| 87 | +
|
| 88 | + # calculate the second value (month number) |
| 89 | + SECOND=$((10#$MONTH)) |
| 90 | +
|
| 91 | + # get the latest tag from the repo |
| 92 | + LATEST_TAG=$(gh release view --json tagName -q '.tagName' 2>/dev/null || echo "0.0.0") |
| 93 | +
|
| 94 | + # extract the first, second, and third values from the latest tag |
| 95 | + LATEST_FIRST=$(echo "$LATEST_TAG" | cut -d. -f1) |
| 96 | + LATEST_SECOND=$(echo "$LATEST_TAG" | cut -d. -f2) |
| 97 | + LATEST_THIRD=$(echo "$LATEST_TAG" | cut -d. -f3) |
| 98 | +
|
| 99 | + # check if year and month match the current values |
| 100 | + if [[ "$FIRST" -eq "$LATEST_FIRST" && "$SECOND" -eq "$LATEST_SECOND" ]]; then |
| 101 | + # increment the third value, it's the n release of the month |
| 102 | + THIRD=$((LATEST_THIRD + 1)) |
| 103 | + else |
| 104 | + # start from 0 if it's the first release of the month |
| 105 | + THIRD=0 |
| 106 | + fi |
| 107 | +
|
| 108 | + # combine the values with full stops |
| 109 | + TAG="${FIRST}.${SECOND}.${THIRD}" |
| 110 | + echo "name=$TAG" >> $GITHUB_OUTPUT |
| 111 | +
|
| 112 | + - name: zip artifacts |
| 113 | + run: | |
| 114 | + for folder in "artifacts"/*; do |
| 115 | + if [ -d "$folder" ]; then |
| 116 | + name=$(basename "$folder") |
| 117 | + zip -jq "${name}-${{ steps.tag.outputs.name }}.zip" "$folder"/* |
| 118 | + tar -cJf "${name}-${{ steps.tag.outputs.name }}.tar.xz" -C "$folder" . |
| 119 | + tar -czf "${name}-${{ steps.tag.outputs.name }}.tar.gz" -C "$folder" . |
| 120 | + fi |
| 121 | + done |
| 122 | +
|
| 123 | + - uses: softprops/[email protected] |
| 124 | + with: |
| 125 | + generate_release_notes: true |
| 126 | + tag_name: ${{ steps.tag.outputs.name }} |
| 127 | + files: | |
| 128 | + js-*-*-${{ steps.tag.outputs.name }}.zip |
| 129 | + js-*-*-${{ steps.tag.outputs.name }}.tar.xz |
| 130 | + js-*-*-${{ steps.tag.outputs.name }}.tar.gz |
| 131 | + make_latest: true |
0 commit comments