diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69a66e53fb..766d700b4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -466,3 +466,95 @@ jobs: path: |- ${{ github.workspace }}/aws-cdk/dist/ ${{ github.workspace }}/aws-cdk/**/dist/ + + push-go-runtime: + needs: build + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: Set up Node 12 + uses: actions/setup-node@v2.1.4 + with: + node-version: '12' + - name: Download Artifact + uses: actions/download-artifact@v2 + with: + name: built-tree + path: ${{ github.workspace }}/jsii-built-tree + - name: Extract Artifact + working-directory: ${{ github.workspace }}/jsii-built-tree + run: |- + echo "::group::Untar Archive" + tar Jxvf built-tree.tar.xz + echo "::endgroup" + + rm built-tree.tar.xz + - name: Get Last Commit Message + id: get-last-commit-msg + working-directory: ${{ github.workspace }}/jsii-built-tree + run: |- + message=$(git log -1 --format=%s) + echo "::set-output name=result::$message" + - name: Locate Caches + id: cache-locations + run: |- + echo "::set-output name=yarn-cache::$(yarn cache dir)" + - name: Cache + uses: actions/cache@v2 + with: + path: |- + ${{ steps.cache-locations.outputs.yarn-cache }} + ${{ github.workspace }}/node_modules + ${{ github.workspace }}/*/*/node_modules + key: ${{ hashFiles('**/yarn.lock') }} + restore-keys: |- + ${{ runner.os }}-yarn- + - name: Install Dependencies + working-directory: ${{ github.workspace }}/jsii-built-tree + run: |- + yarn install --frozen-lockfile + - name: Build Runtime Repo Directory + id: build-repo-dir + run: |- + mkdir ${{ github.workspace }}/jsii-runtime-go + repo_dir=${{ github.workspace }}/jsii-runtime-go + echo "::set-output name=repodir::$repo_dir" + - name: Clone Runtime + uses: actions/checkout@v2 + with: + repository: ${{ secrets.JSII_RUNTIME_REPO_NAME }} + ref: 'main' + token: ${{ secrets.AUTO_APPROVE_GITHUB_TOKEN }} + path: ${{ steps.build-repo-dir.outputs.repodir }} + - name: Copy Runtime Files + working-directory: ${{ github.workspace }}/jsii-built-tree/packages/@jsii/go-runtime + run: |- + yarn ts-node ./build-tools/build-repo-dir.ts ${{ steps.build-repo-dir.outputs.repodir }} + - name: Check for changes + id: check-for-changes + working-directory: ${{ steps.build-repo-dir.outputs.repodir }} + run: |- + git fetch --depth=1 --quiet origin main + git add . + # Check for modifications in tracked files + changed=$(git diff --name-only origin/main) + if [-z "$changed"]; then + echo "::set-output name=result::false" + else + echo "::set-output name=result::true" + fi + - name: Commit and Push + if: steps.check-for-changes.outputs.result == 'true' + working-directory: ${{ steps.build-repo-dir.outputs.repodir }} + run: |- + git config user.name "AWS CDK Automation" + git config user.email "aws-cdk+automation@amazon.com" + git commit -m "${{ steps.get-last-commit-msg.outputs.result }}" + git push + - name: Tag Release + if: github.ref == 'refs/head/release' + run: |- + VERSION=$(node -e 'console.log(require("./lerna.json").version)') + cd ${{ steps.build-repo-dir.outputs.repodir }} + git tag -a $VERSION -m "v$VERSION" + git push $VERSION diff --git a/.github/workflows/push-go-runtime.yml b/.github/workflows/push-go-runtime.yml deleted file mode 100644 index 0fc79d11f9..0000000000 --- a/.github/workflows/push-go-runtime.yml +++ /dev/null @@ -1,78 +0,0 @@ -# Workflows pertaining to the jsii/superchain Docker image -name: Push Jsii Runtime Go - -on: - push: - branches: [main] - -jobs: - push-go-runtime: - name: Build and Publish - runs-on: ubuntu-latest - steps: - - name: Check out - uses: actions/checkout@v2 - - name: Set up Node 10 - uses: actions/setup-node@v2.1.4 - with: - node-version: '10' - - uses: actions/cache@v2 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Install Dependencies - run: |- - # TypeScript project dependencies - yarn install --frozen-lockfile - - name: Align Versions - run: |- - ./scripts/align-version.sh - - name: Build dependencies - run: |- - yarn build \ - --scope codemaker \ - --scope @jsii/spec \ - --scope @jsii/kernel \ - --scope @jsii/runtime - - name: Build - run: |- - yarn build \ - --scope @jsii/go-runtime - - name: Build Repo Directory - id: build-repo-dir - working-directory: ${{ github.workspace }}/packages/@jsii/go-runtime - env: - JSII_RUNTIME_REPO_NAME: ${{ secrets.JSII_RUNTIME_REPO_NAME }} - JSII_RUNTIME_REPO_USERNAME: ${{ secrets.JSII_RUNTIME_REPO_USERNAME }} - JSII_RUNTIME_REPO_TOKEN: ${{ secrets.AUTO_APPROVE_GITHUB_TOKEN }} - run: |- - REPO_DIR=$(mktemp -d) - yarn ts-node ./build-tools/build-repo-dir.ts $REPO_DIR - echo "::set-output name=repodir::$REPO_DIR" - - name: Check for changes - id: check-for-changes - run: |- - # Change directory manually as using `working-directory` doesn't seem to support using outputs from the previous step - cd ${{ steps.build-repo-dir.outputs.repodir }} - git fetch --depth=1 --quiet origin main - git add . - # Check for modifications in tracked files - changed=$(git diff --name-only origin/main) - if [-z "$changed"]; then - echo "::set-output name=result::false" - else - echo "::set-output name=result::true" - fi - - name: Commit and Push - if: steps.check-for-changes.outputs.result == 'true' - env: - JSII_RUNTIME_REPO_NAME: ${{ secrets.JSII_RUNTIME_REPO_NAME }} - JSII_RUNTIME_REPO_USERNAME: ${{ secrets.JSII_RUNTIME_REPO_USERNAME }} - JSII_RUNTIME_REPO_TOKEN: ${{ secrets.AUTO_APPROVE_GITHUB_TOKEN }} - run: |- - MESSAGE=$(git log -1 --format=%s) - cd ${{ steps.build-repo-dir.outputs.repodir }} - git config user.name "$JSII_RUNTIME_REPO_USERNAME" - git config user.email "aws-cdk+automation@amazon.com" - git commit -m "$MESSAGE" - git push https://$JSII_RUNTIME_REPO_USERNAME:$JSII_RUNTIME_REPO_TOKEN@github.com/$JSII_RUNTIME_REPO_NAME.git main diff --git a/packages/@jsii/go-runtime/build-tools/build-repo-dir.ts b/packages/@jsii/go-runtime/build-tools/build-repo-dir.ts index 3f93cdf431..f4cdf983bf 100755 --- a/packages/@jsii/go-runtime/build-tools/build-repo-dir.ts +++ b/packages/@jsii/go-runtime/build-tools/build-repo-dir.ts @@ -1,21 +1,10 @@ #!/usr/bin/env npx ts-node -import { SpawnOptions } from 'child_process'; import * as fs from 'fs-extra'; import * as path from 'path'; -import { runCommand } from './_constants'; - // Constants const RUNTIME_DIR = path.resolve(__dirname, '..', 'jsii-experimental'); -// Destination repo configuration -const REPO_NAME = process.env.JSII_RUNTIME_REPO_NAME; -const USERNAME = process.env.JSII_RUNTIME_REPO_USERNAME; -const TOKEN = process.env.JSII_RUNTIME_REPO_TOKEN; -const REMOTE = - USERNAME && TOKEN - ? `https://${USERNAME}:${TOKEN}@github.com/${REPO_NAME}.git` - : `https://github.com${REPO_NAME}.git`; // Always preserve these files/paths from the cloned repo const PRESERVE = ['.git', '.gitignore']; @@ -28,18 +17,10 @@ const DONT_OVERWRITE = [...PRESERVE, ...ROOT_FILES, ...LOCAL_FILES]; async function main() { const args = process.argv.slice(2); - console.log(args[0]); await makeRepoDir(args[0]); } async function makeRepoDir(dir: string) { - const runRepoCmd = ( - cmd: string, - args: readonly string[], - opts: SpawnOptions = {}, - ) => runCommand(cmd, args, { cwd: dir, ...opts }); - runRepoCmd('git', ['clone', REMOTE, '.'], { stdio: 'inherit' }); - // Clone repo and delete its contents except nodes in the PRESERVE list. const clonedFiles = await fs.readdir(dir); await Promise.all(