Skip to content

Commit

Permalink
chore: Add support for github actions and release-please. (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinyoklion authored Aug 8, 2023
1 parent a1f0d64 commit 8fa0742
Show file tree
Hide file tree
Showing 26 changed files with 297 additions and 244 deletions.
151 changes: 0 additions & 151 deletions .circleci/config.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Use a step like this to build documentation.
name: Build Documentation
description: 'Build Documentation.'

runs:
using: composite
steps:
- name: Build Documentation
shell: bash
run: make doc
28 changes: 28 additions & 0 deletions .github/actions/ci/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a composite to allow sharing these steps into other workflows.
# For instance it could be used by regular CI as well as the release process.

name: CI Workflow
description: "Shared CI workflow."
inputs:
run_tests:
description: "If true, run unit tests, otherwise skip them."
required: false
default: "true"

runs:
using: composite
steps:
- run: make compile
shell: bash
- uses: supercharge/redis-github-action@1.6.0
- run: make ci-tests
shell: bash
- uses: ./.github/actions/build-docs
- run: make dialyze
shell: bash
- run: make build-contract-tests
shell: bash
- run: make start-contract-test-service-bg
shell: bash
- run: make run-contract-tests
shell: bash
20 changes: 20 additions & 0 deletions .github/actions/configure-rebar/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Configure Rebar3
description: 'Configure publishing token for Rebar3'
inputs:
aws_assume_role:
description: 'The ARN of an AWS IAM role to assume. Used to auth with AWS to upload results to S3.'
required: true

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.0
name: 'Get the hex publishing token'
with:
aws_assume_role: ${{ inputs.aws_assume_role }}
ssm_parameter_pairs: '/production/common/releasing/hex/api_key = HEX_AUTH_TOKEN'
- name: Configure rebar3
shell: bash
run: ./.github/scripts/configure_rebar3.sh
env:
HEX_AUTH_TOKEN: ${{ env.HEX_AUTH_TOKEN }}
12 changes: 12 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Publish Documentation
description: 'Publish the documentation to hex.pm and github pages.'

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/publish-pages
name: 'Publish to Github pages'
with:
docs_path: doc
- run: rebar3 hex docs
shell: bash
15 changes: 15 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Publish Package
description: 'Publish the package to Hex.pm'
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
required: true

runs:
using: composite
steps:
- name: Publish Library
shell: bash
run: rebar3 hex publish
# Do not publish a dry run.
if: ${{ inputs.dry_run == 'false' }}
19 changes: 19 additions & 0 deletions .github/scripts/configure_rebar3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Make the directory the configuration should be stored in.
mkdir -p ~/.config/rebar3/

# Create rebar config with hex plugin.
cat >~/.config/rebar3/rebar.config <<EOF
{plugins, [{rebar3_hex, "6.11.9"}]}.
EOF

# Create a hex.config file to allow publishing.
# Note: The indentation here translates to the output file,
# and the EOF must be at the start of the line.
cat >~/.config/rebar3/hex.config <<EOF
%% coding: utf-8
#{<<"hexpm">> =>
#{username => <<"launchdarkly">>,
api_key => <<"${HEX_AUTH_TOKEN}">>}}.
EOF
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Test

on:
push:
branches: [main]
paths-ignore:
- '**.md' #Do not need to run CI for markdown changes.
pull_request:
branches: [main]
paths-ignore:
- '**.md'

jobs:
build-test:
strategy:
matrix:
versions:
- {os: 'ubuntu-20.04', otp: '21.x', rebar: '3.15.2'}
- {os: 'ubuntu-22.04', otp: '24.x', rebar: '3.18.0'}
- {os: 'ubuntu-22.04', otp: '25.x', rebar: '3.18.0'}

runs-on: ${{ matrix.versions.os }}
name: Build and Test - ${{ matrix.versions.otp }}

steps:
- uses: erlef/setup-beam@v1
with:
version-type: loose
otp-version: ${{ matrix.versions.otp }}
rebar3-version: ${{ matrix.versions.rebar }}
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: ./.github/actions/ci
12 changes: 12 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
lint-pr-title:
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
29 changes: 29 additions & 0 deletions .github/workflows/manual-publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
workflow_dispatch:

name: Publish Documentation
jobs:
build-publish:
runs-on: ubuntu-22.04
# Needed to get tokens during publishing.
permissions:
id-token: write
contents: read
steps:
- uses: erlef/setup-beam@v1
with:
version-type: loose
otp-version: 25.x
rebar3-version: 3.18.0
- uses: actions/checkout@v3
- id: build
name: Build Documentation
uses: ./.github/actions/build-docs

- uses: ./.github/actions/configure-rebar
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}

- id: publish
name: Publish Documentation
uses: ./.github/actions/publish-docs
38 changes: 38 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Manual Publish Package
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Is this a dry run. If so no package will be published.'
type: boolean
required: true

jobs:
manual-build-publish:
runs-on: ubuntu-22.04
# Needed to get tokens during publishing.
permissions:
id-token: write
contents: read
steps:
- uses: erlef/setup-beam@v1
with:
version-type: loose
otp-version: 25.x
rebar3-version: 3.18.0
- uses: actions/checkout@v3
- id: build-and-test
# Build using the same steps from CI.
name: Build and Test
uses: ./.github/actions/ci

- uses: ./.github/actions/configure-rebar
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
if: ${{ !inputs.dry_run }}

- id: publish
name: Publish Package
uses: ./.github/actions/publish
with:
dry_run: ${{ inputs.dry_run }}
Loading

0 comments on commit 8fa0742

Please sign in to comment.