Skip to content

Commit

Permalink
Merge branch 'aws-samples:main' into dynamodb-ack
Browse files Browse the repository at this point in the history
  • Loading branch information
thiru85 authored Oct 30, 2023
2 parents c6555d8 + 8f0a123 commit 9f4e170
Show file tree
Hide file tree
Showing 5 changed files with 510 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release
on:
milestone:
types: [closed]

permissions:
id-token: write
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
submodules: recursive
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Release
working-directory: releaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MILESTONE_NUMBER: "${{ github.event.milestone.number }}"
run: |
npm install
npm run exec
- name: Set Git config
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Update stable branch
run: |
git fetch --unshallow
git checkout stable
git pull
git merge --no-ff main -m "Publish to stable"
git push
7 changes: 7 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EKS Workshop - Releases

The EKS Workshop will publish a new version on the last Friday of each month containing all PRs merged to the `main` branch during that time. This will update the content on https://eksworkshop.com and publish a new version to Workshop Studio for AWS events. The changes for the release each month will be publish as a GitHub Release with a corresponding changelog.

There may be releases published off-schedule for specific events like re:Invent and Kubecon, as well as updates made during the month for critical bug fixes.

Each release will have a corresponding GitHub milestone associated with it to track the changes that will be released during that interval. This allows contributors to understand when their contribution will be published, and users of the workshop to understand what changes will be published ahead of time.
108 changes: 108 additions & 0 deletions releaser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Octokit } from "@octokit/rest";

let repository = process.env.GITHUB_REPOSITORY
let sha = process.env.GITHUB_SHA
let milestoneNumber = process.env.MILESTONE_NUMBER

let auth = process.env.GITHUB_TOKEN

let repositoryParts = repository.split('/');
let owner = repositoryParts[0];
let repo = repositoryParts[1];

let tagName = `release-${Math.floor(Date.now() / 1000)}`

const octokit = new Octokit({
auth
});

const categories = [{
title: "## 🚀 New labs",
label: 'new'
}, {
title: "## ✨ Updated labs",
label: 'update'
}, {
title: "## 🐛 Fixes",
label: 'fix'
}, {
title: "## 🧪 Features",
label: 'feat'
}]

let entries = {};

let milestone = await octokit.rest.issues.getMilestone({
owner,
repo,
milestone_number: milestoneNumber,
});

for await (const response of octokit.paginate.iterator(
octokit.rest.pulls.list,
{
owner,
repo,
state: 'closed'
},
)) {
response.data.forEach((e) => {
if(e.milestone) {
if(e.milestone.number == milestoneNumber) {
categories.forEach((c) => {
let targetPrefix = `${c.label}:`;

if(e.title.indexOf(targetPrefix) == 0) {
if(!entries[c.title]) {
entries[c.title] = [];
}

entries[c.title].push({
number: e.number,
title: e.title.substring(targetPrefix.length + 1),
url: e.html_url,
author: {
login: e.user.login,
url: e.user.html_url,
}
});
}
})
}
}
})
}

let output = '';

categories.forEach((c) => {
let categoryOutput = `${c.title}
`;
if(entries[c.title]) {
let categoryEntries = entries[c.title];

if(categoryEntries.length > 0) {
categoryEntries.forEach((e) => {
categoryOutput += `- ${e.title} by [@${e.author.login}](${e.author.url}) ([#${e.number}](${e.url}))\n`
});

output += `${categoryOutput} \n`;
}
}
});

await octokit.rest.git.createRef({
owner,
repo,
ref: `refs/tags/${tagName}`,
sha,
});

await octokit.rest.repos.createRelease({
owner,
repo,
tag_name: tagName,
name: milestone.data.title,
body: output
});
Loading

0 comments on commit 9f4e170

Please sign in to comment.