Skip to content

Commit

Permalink
feat(go): runtime release tagging (#2417)
Browse files Browse the repository at this point in the history
Adds github actions workflows for automatically tagging jsii-runtime-go
when jsii release branch is updated. This essentially publishes new
runtime version. This may eventually be served better in delivlib but is
much simpler in github actions for the alpha phase.

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Romain Marcadier <[email protected]>
  • Loading branch information
3 people authored Jan 14, 2021
1 parent 91454df commit 9ffd204
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 97 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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 "[email protected]"
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
78 changes: 0 additions & 78 deletions .github/workflows/push-go-runtime.yml

This file was deleted.

19 changes: 0 additions & 19 deletions packages/@jsii/go-runtime/build-tools/build-repo-dir.ts
Original file line number Diff line number Diff line change
@@ -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'];
Expand All @@ -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(
Expand Down

0 comments on commit 9ffd204

Please sign in to comment.