release pipeline #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release sqlite-js | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| name: build for ${{ matrix.name }}-${{ matrix.arch }} | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| arch: x86_64 | |
| name: linux | |
| - os: ubuntu-latest #LinuxARM64 | |
| arch: arm64 | |
| name: linux | |
| - os: macos-latest | |
| arch: uni | |
| name: macos | |
| - os: windows-latest | |
| arch: x86_64 | |
| name: windows | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| MAKEFLAGS: -j 8 | |
| steps: | |
| - uses: actions/[email protected] | |
| - name: windows install sqlite3 | |
| if: matrix.os == 'windows-latest' | |
| run: choco install sqlite -y | |
| - name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION | |
| if: matrix.os == 'macos-latest' | |
| run: brew link sqlite --force | |
| - name: build sqlite-js | |
| run: make | |
| - name: test sqlite-js | |
| run: make test | |
| - uses: actions/[email protected] | |
| with: | |
| name: js-${{ matrix.name }}-${{ matrix.arch }} | |
| path: dist/js.* | |
| if-no-files-found: error | |
| release: | |
| runs-on: ubuntu-latest | |
| name: release | |
| needs: build | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/[email protected] | |
| with: | |
| path: artifacts | |
| - name: generate release tag name | |
| id: tag | |
| run: | | |
| # get the current year and month | |
| YEAR=$(date +"%Y") | |
| MONTH=$(date +"%m") | |
| # calculate the first value (year difference from 2025) | |
| FIRST=$((YEAR - 2024)) # 2025 is 1, 2026 is 2, etc. | |
| # calculate the second value (month number) | |
| SECOND=$((10#$MONTH)) | |
| # get the latest tag from the repo | |
| LATEST_TAG=$(gh release view --json tagName -q '.tagName' 2>/dev/null || echo "0.0.0") | |
| # extract the first, second, and third values from the latest tag | |
| LATEST_FIRST=$(echo "$LATEST_TAG" | cut -d. -f1) | |
| LATEST_SECOND=$(echo "$LATEST_TAG" | cut -d. -f2) | |
| LATEST_THIRD=$(echo "$LATEST_TAG" | cut -d. -f3) | |
| # check if year and month match the current values | |
| if [[ "$FIRST" -eq "$LATEST_FIRST" && "$SECOND" -eq "$LATEST_SECOND" ]]; then | |
| # increment the third value, it's the n release of the month | |
| THIRD=$((LATEST_THIRD + 1)) | |
| else | |
| # start from 0 if it's the first release of the month | |
| THIRD=0 | |
| fi | |
| # combine the values with full stops | |
| TAG="${FIRST}.${SECOND}.${THIRD}" | |
| echo "name=$TAG" >> $GITHUB_OUTPUT | |
| - name: zip artifacts | |
| run: | | |
| for folder in "artifacts"/*; do | |
| if [ -d "$folder" ]; then | |
| name=$(basename "$folder") | |
| zip -jq "${name}-${{ steps.tag.outputs.name }}.zip" "$folder"/* | |
| tar -cJf "${name}-${{ steps.tag.outputs.name }}.tar.xz" -C "$folder" . | |
| tar -czf "${name}-${{ steps.tag.outputs.name }}.tar.gz" -C "$folder" . | |
| fi | |
| done | |
| - uses: softprops/[email protected] | |
| with: | |
| generate_release_notes: true | |
| tag_name: ${{ steps.tag.outputs.name }} | |
| files: | | |
| js-*-*-${{ steps.tag.outputs.name }}.zip | |
| js-*-*-${{ steps.tag.outputs.name }}.tar.xz | |
| js-*-*-${{ steps.tag.outputs.name }}.tar.gz | |
| make_latest: true |