feat: initial Turso Elixir client library #4
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 1.0.0)' | |
| required: true | |
| type: string | |
| env: | |
| MIX_ENV: prod | |
| jobs: | |
| # Pre-release validation | |
| validate: | |
| name: Pre-release Validation | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | |
| env: | |
| MIX_ENV: dev | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| tag_version: ${{ steps.version.outputs.tag_version }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag_version=v$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| TAG_VERSION="${GITHUB_REF#refs/tags/}" | |
| VERSION="${TAG_VERSION#v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v3 | |
| with: | |
| install: true | |
| cache: true | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix-prod- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Verify version in mix.exs matches tag | |
| run: | | |
| MIX_VERSION=$(grep -E "@version" mix.exs | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || grep -E "version:" mix.exs | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') | |
| TAG_VERSION="${{ steps.version.outputs.version }}" | |
| if [[ "$MIX_VERSION" != "$TAG_VERSION" ]]; then | |
| echo "Version mismatch: mix.exs has $MIX_VERSION, tag has $TAG_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version validation passed: $TAG_VERSION" | |
| - name: Check for security vulnerabilities | |
| run: mix deps.audit | |
| - name: Compile for production | |
| run: mix compile --warnings-as-errors | |
| - name: Run full test suite | |
| run: | | |
| MIX_ENV=test mix deps.get | |
| MIX_ENV=test mix test | |
| - name: Generate documentation | |
| run: mix docs | |
| # Create GitHub release | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: validate | |
| if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history for changelog generation | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v3 | |
| with: | |
| install: true | |
| cache: true | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix-prod- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Generate documentation | |
| run: mix docs | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| VERSION="${{ needs.validate.outputs.version }}" | |
| # Find previous tag | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^) | |
| if [[ -z "$PREVIOUS_TAG" ]]; then | |
| PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD) | |
| fi | |
| echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT | |
| echo "## What's Changed in v$VERSION" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| # Group commits by type | |
| echo "### ✨ Features" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD | grep -E "^- (feat|add)" || echo "- No new features" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### 🐛 Bug Fixes" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD | grep -E "^- (fix|bug)" || echo "- No bug fixes" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### 📚 Documentation" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD | grep -E "^- (docs|doc)" || echo "- No documentation changes" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### 🔧 Other Changes" >> $GITHUB_OUTPUT | |
| git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD | grep -vE "^- (feat|add|fix|bug|docs|doc)" || echo "- No other changes" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### Installation" >> $GITHUB_OUTPUT | |
| echo "\`\`\`elixir" >> $GITHUB_OUTPUT | |
| echo "def deps do" >> $GITHUB_OUTPUT | |
| echo " [{:turso, \"~> $VERSION\"}]" >> $GITHUB_OUTPUT | |
| echo "end" >> $GITHUB_OUTPUT | |
| echo "\`\`\`" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "**Full Changelog**: [$PREVIOUS_TAG...v$VERSION](https://github.com/${{ github.repository }}/compare/$PREVIOUS_TAG...v$VERSION)" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.validate.outputs.tag_version }} | |
| name: Turso Elixir Client v${{ needs.validate.outputs.version }} | |
| body: ${{ steps.changelog.outputs.CHANGELOG }} | |
| draft: false | |
| prerelease: ${{ contains(needs.validate.outputs.version, '-') }} | |
| files: | | |
| doc/**/* | |
| make_latest: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Publish to Hex.pm | |
| publish: | |
| name: Publish to Hex | |
| runs-on: ubuntu-latest | |
| needs: [validate, release] | |
| if: (startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') && !contains(needs.validate.outputs.version, '-') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v3 | |
| with: | |
| install: true | |
| cache: true | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-prod-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix-prod- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Compile application | |
| run: mix compile --warnings-as-errors | |
| - name: Verify package can be built | |
| run: mix hex.build | |
| - name: Publish to Hex | |
| run: mix hex.publish --yes | |
| env: | |
| HEX_API_KEY: ${{ secrets.HEX_API_KEY }} | |
| # Notification and cleanup | |
| notify: | |
| name: Release Notification | |
| runs-on: ubuntu-latest | |
| needs: [validate, release, publish] | |
| if: always() && (startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch') | |
| steps: | |
| - name: Notify release status | |
| run: | | |
| VERSION="${{ needs.validate.outputs.version }}" | |
| if [[ "${{ needs.release.result }}" == "success" && "${{ needs.publish.result }}" == "success" ]]; then | |
| echo "✅ Turso Elixir Client v$VERSION successfully released!" | |
| echo "📦 Hex package: https://hex.pm/packages/turso/$VERSION" | |
| echo "📋 GitHub release: https://github.com/${{ github.repository }}/releases/tag/v$VERSION" | |
| echo "📚 Documentation: https://hexdocs.pm/turso/$VERSION" | |
| elif [[ "${{ needs.release.result }}" == "success" && "${{ needs.publish.result }}" == "skipped" ]]; then | |
| echo "✅ Pre-release v$VERSION created on GitHub (Hex publishing skipped for pre-release)" | |
| echo "📋 GitHub release: https://github.com/${{ github.repository }}/releases/tag/v$VERSION" | |
| else | |
| echo "❌ Release pipeline failed for v$VERSION" | |
| echo "Release result: ${{ needs.release.result }}" | |
| echo "Publish result: ${{ needs.publish.result }}" | |
| exit 1 | |
| fi |