diff --git a/src/SDK/Language/Dart.php b/src/SDK/Language/Dart.php index b61380a01..eb0052fb6 100644 --- a/src/SDK/Language/Dart.php +++ b/src/SDK/Language/Dart.php @@ -475,8 +475,13 @@ public function getFiles(): array ], [ 'scope' => 'default', - 'destination' => '.travis.yml', - 'template' => 'dart/.travis.yml.twig', + 'destination' => '.github/workflows/publish.yml', + 'template' => 'dart/.github/workflows/publish.yml.twig', + ], + [ + 'scope' => 'default', + 'destination' => '.github/workflows/format.yml', + 'template' => 'dart/.github/workflows/format.yml.twig', ], [ 'scope' => 'default', diff --git a/src/SDK/Language/Flutter.php b/src/SDK/Language/Flutter.php index 77f5c66bf..6c6fd8f17 100644 --- a/src/SDK/Language/Flutter.php +++ b/src/SDK/Language/Flutter.php @@ -332,8 +332,13 @@ public function getFiles(): array ], [ 'scope' => 'default', - 'destination' => '.travis.yml', - 'template' => 'flutter/.travis.yml.twig', + 'destination' => '.github/workflows/publish.yml', + 'template' => 'flutter/.github/workflows/publish.yml.twig', + ], + [ + 'scope' => 'default', + 'destination' => '.github/workflows/format.yml', + 'template' => 'flutter/.github/workflows/format.yml.twig', ], [ 'scope' => 'enum', diff --git a/src/SDK/Language/Node.php b/src/SDK/Language/Node.php index 45fdb72f7..d6e0a072f 100644 --- a/src/SDK/Language/Node.php +++ b/src/SDK/Language/Node.php @@ -234,8 +234,8 @@ public function getFiles(): array ], [ 'scope' => 'default', - 'destination' => '.travis.yml', - 'template' => 'node/.travis.yml.twig', + 'destination' => '.github/workflows/publish.yml', + 'template' => 'node/.github/workflows/publish.yml.twig', ], [ 'scope' => 'enum', diff --git a/src/SDK/Language/Web.php b/src/SDK/Language/Web.php index e29d0d0f1..105e86cd1 100644 --- a/src/SDK/Language/Web.php +++ b/src/SDK/Language/Web.php @@ -112,8 +112,8 @@ public function getFiles(): array ], [ 'scope' => 'default', - 'destination' => '.travis.yml', - 'template' => 'web/.travis.yml.twig', + 'destination' => '.github/workflows/publish.yml', + 'template' => 'web/.github/workflows/publish.yml.twig', ], [ 'scope' => 'enum', diff --git a/templates/dart/.github/workflows/format.yml.twig b/templates/dart/.github/workflows/format.yml.twig new file mode 100644 index 000000000..3926b5ab0 --- /dev/null +++ b/templates/dart/.github/workflows/format.yml.twig @@ -0,0 +1,33 @@ +name: Format and push + +# Github action will require permission to write to repo +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + format: + runs-on: ubuntu-latest + container: + image: dart:stable + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: true + ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }} + + - name: Format Dart code + run: dart format . + + - name: git config + run: git config --global --add safe.directory /__w/sdk-for-dart/sdk-for-dart # required to fix dubious ownership + + - name: Add & Commit + uses: EndBug/add-and-commit@v9.1.4 + with: + add: lib + diff --git a/templates/dart/.github/workflows/publish.yml.twig b/templates/dart/.github/workflows/publish.yml.twig new file mode 100644 index 000000000..b40c5074b --- /dev/null +++ b/templates/dart/.github/workflows/publish.yml.twig @@ -0,0 +1,14 @@ +name: Publish to pub.dev + +on: + push: + tags: + - '[0-9]+\.[0-9]+\.[0-9]+.*' + +jobs: + publish: + permissions: + id-token: write + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + environment: pub.dev \ No newline at end of file diff --git a/templates/dart/.travis.yml.twig b/templates/dart/.travis.yml.twig deleted file mode 100644 index 38001f43e..000000000 --- a/templates/dart/.travis.yml.twig +++ /dev/null @@ -1,24 +0,0 @@ -language: dart - -dart: stable - -os: linux - -install: -- mkdir -p ~/.config/dart -- | - cat < ~/.config/dart/pub-credentials.json - { - "accessToken":"$PUB_ACCESS_TOKEN", - "refreshToken":"$PUB_REFRESH_TOKEN", - "tokenEndpoint":"$PUB_TOKEN_EDNPOINT", - "scopes":["https://www.googleapis.com/auth/plus.me","https://www.googleapis.com/auth/userinfo.email"], - "expiration":$PUB_EXPIRATION - } - -deploy: - provider: script - skip_cleanup: true - script: dart format ./lib/ && dart pub publish -f - on: - tags: true \ No newline at end of file diff --git a/templates/flutter/.github/workflows/format.yml.twig b/templates/flutter/.github/workflows/format.yml.twig new file mode 100644 index 000000000..ae216a5fc --- /dev/null +++ b/templates/flutter/.github/workflows/format.yml.twig @@ -0,0 +1,33 @@ +name: Format and push + +# Github action will require permission to write to repo +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + format: + runs-on: ubuntu-latest + container: + image: dart:stable + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: true + ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }} + + - name: Format Dart code + run: dart format . + + - name: git config + run: git config --global --add safe.directory /__w/sdk-for-flutter/sdk-for-flutter # required to fix dubious ownership + + - name: Add & Commit + uses: EndBug/add-and-commit@v9.1.4 + with: + add: lib + diff --git a/templates/flutter/.github/workflows/publish.yml.twig b/templates/flutter/.github/workflows/publish.yml.twig new file mode 100644 index 000000000..a8584faaa --- /dev/null +++ b/templates/flutter/.github/workflows/publish.yml.twig @@ -0,0 +1,14 @@ +name: Publish to pub.dev + +on: + push: + tags: + - '[0-9]+\.[0-9]+\.[0-9]+.*' + +jobs: + publish: + permissions: + id-token: write + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 + with: + environment: pub.dev diff --git a/templates/flutter/.travis.yml.twig b/templates/flutter/.travis.yml.twig deleted file mode 100644 index 0e2d21508..000000000 --- a/templates/flutter/.travis.yml.twig +++ /dev/null @@ -1,29 +0,0 @@ -language: dart - -dart: stable - -os: linux - -install: -- cd ~ -- git clone https://github.com/flutter/flutter.git -b stable --depth 1 -- export PATH="$PATH:$(pwd)/flutter/bin/cache/dart-sdk/bin" -- export PATH="$PATH:$(pwd)/flutter/bin" -- flutter doctor -- mkdir -p ~/.config/dart -- | - cat < ~/.config/dart/pub-credentials.json - { - "accessToken":"$PUB_ACCESS_TOKEN", - "refreshToken":"$PUB_REFRESH_TOKEN", - "tokenEndpoint":"$PUB_TOKEN_EDNPOINT", - "scopes":["https://www.googleapis.com/auth/plus.me","https://www.googleapis.com/auth/userinfo.email"], - "expiration":$PUB_EXPIRATION - } - -deploy: - provider: script - skip_cleanup: true - script: cd $TRAVIS_BUILD_DIR && dart format ./lib/ && dart format ./test/ && flutter pub publish -f - on: - tags: true diff --git a/templates/node/.github/workflows/publish.yml.twig b/templates/node/.github/workflows/publish.yml.twig new file mode 100644 index 000000000..3dda7aa9b --- /dev/null +++ b/templates/node/.github/workflows/publish.yml.twig @@ -0,0 +1,42 @@ +name: Publish to NPM + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + # Setup Node.js environment + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + + # Determine release tag based on the tag name + - name: Determine release tag + id: release_tag + run: | + if [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-rc"* ]] || [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-RC"* ]]; then + echo "tag=next" >> "$GITHUB_OUTPUT" + else + echo "tag=latest" >> "$GITHUB_OUTPUT" + fi + + # Install dependencies (if any) and build your project (if necessary) + - name: Install dependencies and build + run: | + npm install + npm run build + + # Publish to NPM with the appropriate tag + - name: Publish + run: npm publish --tag ${{ '{{' }} steps.release_tag.outputs.tag {{ '}}' }} + env: + NODE_AUTH_TOKEN: ${{ '{{' }} secrets.NPM_TOKEN {{ '}}' }} diff --git a/templates/node/.travis.yml.twig b/templates/node/.travis.yml.twig deleted file mode 100644 index 614269a65..000000000 --- a/templates/node/.travis.yml.twig +++ /dev/null @@ -1,32 +0,0 @@ -language: node_js -node_js: - - "16" - -jobs: - include: - - stage: NPM RC Release - if: tag =~ /-(rc|RC)/ - node_js: "16" - script: - - npm install - - npm run build - - echo "Deploying RC to NPM..." - deploy: - provider: npm - email: $NPM_EMAIL - api_key: $NPM_API_KEY - tag: next - - stage: NPM Release - if: not tag =~ /-(rc|RC)/ - node_js: "16" - script: - - npm install - - npm run build - - echo "Deploying to NPM..." - deploy: - provider: npm - email: $NPM_EMAIL - api_key: $NPM_API_KEY - skip_cleanup: true - on: - tags: true \ No newline at end of file diff --git a/templates/web/.github/workflows/publish.yml.twig b/templates/web/.github/workflows/publish.yml.twig new file mode 100644 index 000000000..3dda7aa9b --- /dev/null +++ b/templates/web/.github/workflows/publish.yml.twig @@ -0,0 +1,42 @@ +name: Publish to NPM + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + # Setup Node.js environment + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + + # Determine release tag based on the tag name + - name: Determine release tag + id: release_tag + run: | + if [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-rc"* ]] || [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-RC"* ]]; then + echo "tag=next" >> "$GITHUB_OUTPUT" + else + echo "tag=latest" >> "$GITHUB_OUTPUT" + fi + + # Install dependencies (if any) and build your project (if necessary) + - name: Install dependencies and build + run: | + npm install + npm run build + + # Publish to NPM with the appropriate tag + - name: Publish + run: npm publish --tag ${{ '{{' }} steps.release_tag.outputs.tag {{ '}}' }} + env: + NODE_AUTH_TOKEN: ${{ '{{' }} secrets.NPM_TOKEN {{ '}}' }} diff --git a/templates/web/.travis.yml.twig b/templates/web/.travis.yml.twig deleted file mode 100644 index 564159b38..000000000 --- a/templates/web/.travis.yml.twig +++ /dev/null @@ -1,32 +0,0 @@ -language: node_js -node_js: - - "14.16" - -jobs: - include: - - stage: NPM RC Release - if: tag =~ /-(rc|RC)/ - node_js: "14.16" - script: - - npm install - - npm run build - - echo "Deploying RC to NPM..." - deploy: - provider: npm - email: $NPM_EMAIL - api_key: $NPM_API_KEY - tag: next - - stage: NPM Release - if: not tag =~ /-(rc|RC)/ - node_js: "14.16" - script: - - npm install - - npm run build - - echo "Deploying to NPM..." - deploy: - provider: npm - email: $NPM_EMAIL - api_key: $NPM_API_KEY - skip_cleanup: true - on: - tags: true \ No newline at end of file