Skip to content

Commit

Permalink
chore(ci): add relaease automation with semantic release (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed Mar 9, 2021
1 parent 69ca98e commit 206cec3
Show file tree
Hide file tree
Showing 17 changed files with 4,989 additions and 87 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lambda-runner-binaries-syncer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env:
on:
push:
branches:
- master
- develop
pull_request:
paths:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/lambda-runners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Lambda Runners
on:
push:
branches:
- master
- develop
pull_request:
paths:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/lambda-webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Lambda Webhook
on:
push:
branches:
- master
- develop
pull_request:
paths:
Expand Down
115 changes: 61 additions & 54 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,80 @@ name: Release build

on:
push:
tags:
- v*
branches:
- master
- develop

jobs:
release:
name: Build runners distribution
prepare:
name: Create dist
runs-on: ubuntu-latest
container: node:12
env:
lambda_webhook_name: webhook
lambda_runners_name: runners
lambda_syncer_name: runner-binaries-syncer
strategy:
matrix:
lambda: ["modules/webhook/lambdas/webhook", "modules/runner-binaries-syncer/lambdas/runner-binaries-syncer", "modules/runners/lambdas/runners"]
steps:
- name: Create Release
id: create_release
uses: actions/create-release@latest
- name: Extract lambda name
id: lambda
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: true
- name: Extract tag name
id: tag_name
run: echo ::set-output name=TAG::${GITHUB_REF##*/}
LAMBDA: ${{ matrix.lambda }}
run: echo ::set-output name=name::${LAMBDA##*/}
- uses: actions/checkout@v2
- name: Add zip
run: apt update && apt install zip
- name: Build dist
working-directory: ${{ matrix.lambda }}
run: yarn install && yarn run test && yarn dist
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.lambda.outputs.name }}
path: ${{ matrix.lambda }}/${{ steps.lambda.outputs.name }}.zip
retention-days: 1

- name: Lambda webhook - build
working-directory: modules/webhook/lambdas/webhook
run: yarn install && yarn dist
- name: Lambda webhook - Upload asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
runs-on: ubuntu-latest
needs:
prepare
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v2
with:
name: webhook
path: artifacts
- uses: actions/download-artifact@v2
with:
name: runners
path: artifacts
- uses: actions/download-artifact@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: modules/${{ env.lambda_webhook_name }}/lambdas/${{ env.lambda_webhook_name }}/${{ env.lambda_webhook_name }}.zip
asset_name: ${{ env.lambda_webhook_name }}-${{ steps.tag_name.outputs.TAG }}.zip
asset_content_type: application/zip
name: runner-binaries-syncer
path: artifacts

- name: Lambda syncer - build
working-directory: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer
run: yarn install && yarn dist
- name: Lambda syncer - Upload asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get installation token
uses: npalm/action-app-token@v1.0.0
id: app-token
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: modules/${{ env.lambda_syncer_name }}/lambdas/${{ env.lambda_syncer_name }}/${{ env.lambda_syncer_name }}.zip
asset_name: ${{ env.lambda_syncer_name }}-${{ steps.tag_name.outputs.TAG }}.zip
asset_content_type: application/zip
appId: ${{ secrets.FOREST_RELEASER_APP_ID }}
appPrivateKeyBase64: ${{ secrets.FOREST_RELEASER_APP_PRIVATE_KEY_BASE64 }}
appInstallationType: repo
appInstallationValue: ${{ github.repository }}

- name: Lambda runners - build
- name: Release
if: github.event_name != 'pull_request' && contains('refs/heads/master', github.ref)
env:
lambda_path: modules/runners/lambdas/runners
working-directory: modules/runners/lambdas/runners
run: yarn install && yarn dist
- name: Lambda runners - Upload asset
uses: actions/upload-release-asset@v1
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cp .release/* .
yarn
yarn release -d --repositoryUrl https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git
- name: Dry run release
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: modules/${{ env.lambda_runners_name }}/lambdas/${{ env.lambda_runners_name }}/${{ env.lambda_runners_name }}.zip
asset_name: ${{ env.lambda_runners_name }}-${{ steps.tag_name.outputs.TAG }}.zip
asset_content_type: application/zip
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cp .release/* .
yarn
yarn release -d --repositoryUrl https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.45.0
rev: v1.47.0
hooks:
- id: terraform_fmt
- id: terraform_tflint
- id: terraform_docs
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v3.4.0
hooks:
- id: check-merge-conflict
18 changes: 18 additions & 0 deletions .release/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "terraform",
"description": "Install semantic release packages",
"scripts": {
"release": "semantic-release"
},
"author": "Niek Palm",
"devDependencies": {
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.2.0",
"@semantic-release/release-notes-generator": "^9.0.1",
"conventional-changelog-conventionalcommits": "^4.5.0",
"semantic-release": "^17.3.9"
}
}
Loading

0 comments on commit 206cec3

Please sign in to comment.