Skip to content

Commit b44b074

Browse files
Merge pull request #842 from appwrite/feat-publishing-with-github-action
Publish SDKs with Github Action
2 parents 1b92c76 + c396ed8 commit b44b074

File tree

14 files changed

+196
-125
lines changed

14 files changed

+196
-125
lines changed

src/SDK/Language/Dart.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,13 @@ public function getFiles(): array
475475
],
476476
[
477477
'scope' => 'default',
478-
'destination' => '.travis.yml',
479-
'template' => 'dart/.travis.yml.twig',
478+
'destination' => '.github/workflows/publish.yml',
479+
'template' => 'dart/.github/workflows/publish.yml.twig',
480+
],
481+
[
482+
'scope' => 'default',
483+
'destination' => '.github/workflows/format.yml',
484+
'template' => 'dart/.github/workflows/format.yml.twig',
480485
],
481486
[
482487
'scope' => 'default',

src/SDK/Language/Flutter.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,13 @@ public function getFiles(): array
332332
],
333333
[
334334
'scope' => 'default',
335-
'destination' => '.travis.yml',
336-
'template' => 'flutter/.travis.yml.twig',
335+
'destination' => '.github/workflows/publish.yml',
336+
'template' => 'flutter/.github/workflows/publish.yml.twig',
337+
],
338+
[
339+
'scope' => 'default',
340+
'destination' => '.github/workflows/format.yml',
341+
'template' => 'flutter/.github/workflows/format.yml.twig',
337342
],
338343
[
339344
'scope' => 'enum',

src/SDK/Language/Node.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ public function getFiles(): array
234234
],
235235
[
236236
'scope' => 'default',
237-
'destination' => '.travis.yml',
238-
'template' => 'node/.travis.yml.twig',
237+
'destination' => '.github/workflows/publish.yml',
238+
'template' => 'node/.github/workflows/publish.yml.twig',
239239
],
240240
[
241241
'scope' => 'enum',

src/SDK/Language/Web.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public function getFiles(): array
112112
],
113113
[
114114
'scope' => 'default',
115-
'destination' => '.travis.yml',
116-
'template' => 'web/.travis.yml.twig',
115+
'destination' => '.github/workflows/publish.yml',
116+
'template' => 'web/.github/workflows/publish.yml.twig',
117117
],
118118
[
119119
'scope' => 'enum',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Format and push
2+
3+
# Github action will require permission to write to repo
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
format:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: dart:stable
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
persist-credentials: true
21+
ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }}
22+
23+
- name: Format Dart code
24+
run: dart format .
25+
26+
- name: git config
27+
run: git config --global --add safe.directory /__w/sdk-for-dart/sdk-for-dart # required to fix dubious ownership
28+
29+
- name: Add & Commit
30+
uses: EndBug/add-and-commit@v9.1.4
31+
with:
32+
add: lib
33+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+\.[0-9]+\.[0-9]+.*'
7+
8+
jobs:
9+
publish:
10+
permissions:
11+
id-token: write
12+
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
13+
with:
14+
environment: pub.dev

templates/dart/.travis.yml.twig

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Format and push
2+
3+
# Github action will require permission to write to repo
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
format:
12+
runs-on: ubuntu-latest
13+
container:
14+
image: dart:stable
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
persist-credentials: true
21+
ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }}
22+
23+
- name: Format Dart code
24+
run: dart format .
25+
26+
- name: git config
27+
run: git config --global --add safe.directory /__w/sdk-for-flutter/sdk-for-flutter # required to fix dubious ownership
28+
29+
- name: Add & Commit
30+
uses: EndBug/add-and-commit@v9.1.4
31+
with:
32+
add: lib
33+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+\.[0-9]+\.[0-9]+.*'
7+
8+
jobs:
9+
publish:
10+
permissions:
11+
id-token: write
12+
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
13+
with:
14+
environment: pub.dev

templates/flutter/.travis.yml.twig

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish to NPM
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
# Setup Node.js environment
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20.x'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
# Determine release tag based on the tag name
23+
- name: Determine release tag
24+
id: release_tag
25+
run: |
26+
if [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-rc"* ]] || [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-RC"* ]]; then
27+
echo "tag=next" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "tag=latest" >> "$GITHUB_OUTPUT"
30+
fi
31+
32+
# Install dependencies (if any) and build your project (if necessary)
33+
- name: Install dependencies and build
34+
run: |
35+
npm install
36+
npm run build
37+
38+
# Publish to NPM with the appropriate tag
39+
- name: Publish
40+
run: npm publish --tag ${{ '{{' }} steps.release_tag.outputs.tag {{ '}}' }}
41+
env:
42+
NODE_AUTH_TOKEN: ${{ '{{' }} secrets.NPM_TOKEN {{ '}}' }}

templates/node/.travis.yml.twig

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish to NPM
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
# Setup Node.js environment
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20.x'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
# Determine release tag based on the tag name
23+
- name: Determine release tag
24+
id: release_tag
25+
run: |
26+
if [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-rc"* ]] || [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-RC"* ]]; then
27+
echo "tag=next" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "tag=latest" >> "$GITHUB_OUTPUT"
30+
fi
31+
32+
# Install dependencies (if any) and build your project (if necessary)
33+
- name: Install dependencies and build
34+
run: |
35+
npm install
36+
npm run build
37+
38+
# Publish to NPM with the appropriate tag
39+
- name: Publish
40+
run: npm publish --tag ${{ '{{' }} steps.release_tag.outputs.tag {{ '}}' }}
41+
env:
42+
NODE_AUTH_TOKEN: ${{ '{{' }} secrets.NPM_TOKEN {{ '}}' }}

templates/web/.travis.yml.twig

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)