Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

One App release process #90

Merged
merged 27 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
505528d
feat(release): add release process for one app using github actions
nellyk Mar 31, 2020
e247e0e
feat(release): add release process for one app
nellyk Apr 2, 2020
b0878e0
feat(release): add release process for one app
nellyk Apr 2, 2020
088a20a
feat(release): add release process for one app
nellyk Apr 3, 2020
7e1bec2
Merge branch 'master' into feat/one-app-release
nellyk Apr 3, 2020
835ee5b
feat(release): add release process for one app
nellyk Apr 3, 2020
6327701
Merge branch 'feat/one-app-release' of https://github.com/americanexp…
nellyk Apr 3, 2020
5501bec
feat(release): add release process for one app
nellyk Apr 3, 2020
2d9e6d2
feat(release): add release process for one app
nellyk Apr 3, 2020
2471bd9
feat(release): github actions
nellyk Apr 3, 2020
88d2a2a
chore(actions): updated as per pr reviews
nellyk Apr 7, 2020
d5efa6a
chore(release): updated as per reviews
nellyk Apr 7, 2020
08ca988
chore(release): updated as per pr review comments
nellyk Apr 7, 2020
100d7a2
chore(release): updated as per pr reviews
nellyk Apr 7, 2020
6d635bd
chore(actions): updated as per pr reviews
nellyk Apr 7, 2020
cb09c02
Merge branch 'feat/one-app-release' of https://github.com/americanexp…
nellyk Apr 7, 2020
ec63975
Merge branch 'master' into feat/one-app-release
JAdshead Apr 7, 2020
5e01fea
chore(release): pr feedback
nellyk Apr 8, 2020
22cd6f2
chore(release): pr reviews
nellyk Apr 8, 2020
c376ce4
chore(release): pr reviews
nellyk Apr 8, 2020
fe51a45
chore(release): pr review update
nellyk Apr 8, 2020
4b91119
Merge branch 'master' into feat/one-app-release
nellyk Apr 8, 2020
5b53c41
Merge branch 'master' into feat/one-app-release
JAdshead Apr 8, 2020
8605366
chore(actions): updated as per pr reviews
nellyk Apr 8, 2020
dc4a22d
chore(actions): updated as per pr reviews
nellyk Apr 8, 2020
4b4e48c
Merge branch 'feat/one-app-release' of https://github.com/americanexp…
nellyk Apr 8, 2020
43fb28b
Merge branch 'master' into feat/one-app-release
JAdshead Apr 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
exclude-labels:
- 'skip-release-drafter'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
## Changes

$CHANGES
69 changes: 69 additions & 0 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: One App Docker Release
on:
push:
tags:
- '*'
infoxicator marked this conversation as resolved.
Show resolved Hide resolved
repository_dispatch:
types: [one-app-docker-release]
jobs:
one-app-docker-release:
name: Build and Deploy to Docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: Set env
id: set_tag_version
run: |
if [ "${{ github.event.client_payload.tagversion }}" != "" ]; then
echo ::set-output name=tagversion::${{ github.event.client_payload.tagversion }}
else
echo ::set-output name=tagversion::$(echo $GITHUB_REF | cut -d / -f 3)
fi
echo $tagversion
- name: Docker login
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
- name: Build production docker image
run: docker build -t prod .
- name: Extract and zip production statics
run: |
docker cp $(docker create prod):opt/one-app/build ./one-app-statics
zip -r one-app-static-assets one-app-statics/build
- name: Publish statics to NPM
run: npm publish ./one-app-statics --access public
Francois-Esquire marked this conversation as resolved.
Show resolved Hide resolved
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Build development docker image
run: docker build -t dev . --target=development
- name: Tag Docker Images
run: |
docker tag prod ${{ secrets.DOCKER_USER }}/one-app:${{ steps.set_tag_version.outputs.tagversion }}
docker tag dev ${{ secrets.DOCKER_USER }}/one-app-dev:${{ steps.set_tag_version.outputs.tagversion }}
- name: Push Docker Images
run: |
docker push ${{ secrets.DOCKER_USER }}/one-app:${{ steps.set_tag_version.outputs.tagversion }}
docker push ${{ secrets.DOCKER_USER }}/one-app-dev:${{ steps.set_tag_version.outputs.tagversion }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.set_tag_version.outputs.tagversion }}
release_name: Release ${{ steps.set_tag_version.outputs.tagversion }}
draft: false
prerelease: false
- name: Upload Release Assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./one-app-static-assets.zip
asset_name: one-app-static-assets.zip
asset_content_type: application/zip
37 changes: 37 additions & 0 deletions .github/workflows/pull_request_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: One App Release Pull Request
on:
schedule:
- cron: "0 16 * * 3"
jobs:
one-app-release-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v1
with:
node-version: 12.x
- name: One App release
id: vars
run: |
NODE_ENV=development npm ci
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do?

env:
  NODE_ENV: development

Not a blocker, but just curious.

git config --local user.email "one.amex@aexp.com"
git config --local user.name "OneAmexBot"
npm run release
- name: Create release pull request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.PA_TOKEN }}
commit-message: One App Prepare Release
committer: 'OneAmexBot <one.amex@aexp.com>'
author: 'OneAmexBot <one.amex@aexp.com>'
title: 'One App Prepare Release'
body: 'This is an auto-generated pull request for One App release changes. Please review this PR and merge it for a release to be initiated. Please close this PR to stop a release from being initiated.'
labels: release,automated pr,skip-release-drafter
branch: prepare-release
base: master
14 changes: 14 additions & 0 deletions .github/workflows/release_drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/tagging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tagging release
on:
pull_request:
types:
- closed
branches:
- master
jobs:
tagging-release:
name: Tagging release
runs-on: ubuntu-latest
if: github.event.pull_request.merged && github.head_ref == 'prepare-release' && github.base_ref == 'master'
steps:
- uses: actions/checkout@v2
- name: get commit message
shell: bash
run: |
echo ::set-env name=commitmsg::$(git log --format=%B -n 1 ${{ github.event.after }})
echo $commitmsg
- name: get tag version
run: |
echo ::set-env name=tagversion::$( sed -e 's#.*: \(\)#\1#' <<< ${commitmsg} )
echo $tagversion
- name: set tag version
id: set_tag_version
run: |
git config --local user.email "one.amex@aexp.com"
git config --local user.name "OneAmexBot"
echo ${tagversion}
git tag ${tagversion}
git push origin --tags
echo ::set-output name=action_tag::${tagversion}
- name: Trigger Image Publishing
Francois-Esquire marked this conversation as resolved.
Show resolved Hide resolved
uses: octokit/request-action@v2.x
id: dispatch_one-app-docker-release
with:
route: POST /repos/:repository/dispatches
repository: ${{ github.repository }}
mediaType: '{"previews": ["everest"]}'
event_type: "one-app-docker-release"
client_payload: '{"tagversion": "${{ steps.set_tag_version.outputs.action_tag }}"}'
env:
GITHUB_TOKEN: ${{ secrets.PA_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<img src='https://github.com/americanexpress/one-app/raw/master/one-app.png' alt="One App - One Amex" width='50%'/>
</h1>

![One App Docker Release](https://github.com/americanexpress/one-app/workflows/One%20App%20Docker%20Release/badge.svg)

One App is a fresh take on web application development. It consists of a [Node.js](https://nodejs.org)
server that serves up a single page app built using [React] components and
makes use of [Holocron](https://github.com/americanexpress/holocron) to allow for code splitting
Expand Down
56 changes: 56 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# One App release process

This defines the One App release process.

Releases can be triggered in two ways:

- [Automated release process](#automated-release-process)
- [Manual release process](#manual-release-process)

## Automated release process

1. An automated pull request will be raised every Wednesday at 16:00 UTC, from a `prepare-release` branch to master. This uses [pull_request_release workflow](.github/workflows/pull_request_release.yml) and updates the [package.json](package.json), [package-lock.json](package-lock.json), [one-app-statics package.json](one-app-statics/package.json) and the changelog. Behind the scene it uses [standard-version](https://github.com/conventional-changelog/standard-version) to generate and update these files with the changes for released. The commit message contains will be in the following format `chore(release): X.X.X` . You can update this pull request to remove or add any new changes.
2. Once a pull request is reviewed merge the pull request and please ensure that the commit message is updated to follow this pattern

``` bash
#chore(release): v5.0.0
chore(release): v<semantic-version>

```

> Integration tests will continue to run in Travis as they currently do, after the automated pull request is created it would run the tests on `prepare-release` branch.

1. The merge will trigger the automatic generation of a new tag using the semantic version provided during the merging of the pull request above.

2. After the the generated tag is pushed to the branch this will trigger the docker build and publish the statics and push the images to Docker Hub. The development and production images would be accessible in docker [https://hub.docker.com/u/oneamex](https://hub.docker.com/u/oneamex)

3. We are currently using [https://github.com/release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) to generate release notes. Please add the labels specified within [release-drafter](.github/release-drafter.yml) to categorize different pull requests. Update the draft release notes and tie it to the release tag above, you can also link this to different artifacts. The statics assets will be published and added to a tag that has been released.

## Manual release process

This process can be used to make ad hoc releases outside of wednesday release cycle.

1. Run `npm run release` locally within your branch, this would update the changelog, [package.json](package.json), [package-lock.json](package-lock.json)and [one-app-statics package.json](one-app-statics/package.json) with the new version to be released. Push your changes and create a pull request to master.
2. When the changes are merged and reviewed. The same process from step 3 above will be followed.

## FAQs

### How can I revert a release?
nellyk marked this conversation as resolved.
Show resolved Hide resolved

If changes were made and need to be reverted. Please use the [manual release process](#manual-release-process) to revert the changes and raise a patch release.

### How can I run the first release?

For the first release please use the [manual release process](#manual-release-process). Run `npm run release -- --first-release` to generate the initial changelog and update the package.json files.

### How can I create a prerelease?

For the first release please use the [manual release process](#manual-release-process). Run `npm run release -- --prerelease` to generate the initial changelog and update the package.json files.

### What happens if a pull request merged after the automated pull request is created?

We should try to prevent this from happening, but if it does happen, since the pull request runs every wednesday it won't be triggered again and updated. Follow the above [manual release process](#manual-release-process) to include the changes that have been merged.

### How can I do a dry run to test out the files to be changed locally

Locally you can run `npm run release -- --dry-run`, this would show the new version to be released, the files that would changed and a view of the changelog without changing any of the files.
Loading