|
| 1 | +# Triggered on version tags (v*) or manually. |
| 2 | + |
| 3 | +name: Release |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + version: |
| 13 | + description: 'Version tag (e.g., v1.0.0, v1.0.0-beta.1)' |
| 14 | + required: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + validate: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + version: ${{ steps.version.outputs.version }} |
| 21 | + steps: |
| 22 | + - name: Determine version |
| 23 | + id: version |
| 24 | + run: | |
| 25 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 26 | + VERSION="${{ github.ref_name }}" |
| 27 | + else |
| 28 | + VERSION="${{ inputs.version }}" |
| 29 | + fi |
| 30 | +
|
| 31 | + if ! echo "$VERSION" | grep -qE '^v?[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then |
| 32 | + echo "Error: Invalid version format: $VERSION" |
| 33 | + echo "Expected: vMAJOR.MINOR.PATCH[-prerelease][+metadata]" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +
|
| 37 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 38 | + echo "Version: $VERSION" |
| 39 | +
|
| 40 | + test: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + fetch-depth: '0' |
| 46 | + - uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version-file: '.node-version' |
| 49 | + - name: Setup pnpm |
| 50 | + uses: pnpm/action-setup@v4 |
| 51 | + with: |
| 52 | + version: 10 |
| 53 | + - name: Setup just |
| 54 | + run: | |
| 55 | + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to $HOME/.local/bin |
| 56 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 57 | + - name: 🚀 Lint 🚀 |
| 58 | + run: just lint |
| 59 | + |
| 60 | + deploy: |
| 61 | + needs: [test, validate] |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + with: |
| 66 | + fetch-depth: '0' |
| 67 | + - uses: actions/setup-node@v4 |
| 68 | + with: |
| 69 | + node-version-file: '.node-version' |
| 70 | + - name: Setup pnpm |
| 71 | + uses: pnpm/action-setup@v4 |
| 72 | + with: |
| 73 | + version: 10 |
| 74 | + - name: Setup just |
| 75 | + run: | |
| 76 | + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to $HOME/.local/bin |
| 77 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 78 | + - name: 🚀 Deploy 🚀 |
| 79 | + run: just deploy |
| 80 | + env: |
| 81 | + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 82 | + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
0 commit comments