Skip to content

Commit

Permalink
WIP: Added a deployment process.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesiarmes committed Oct 8, 2024
1 parent c3a97fb commit 88374fc
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release module
on:
pull_request:
workflow_dispatch:
inputs:
module_path:
description: 'Path to the module to be released'
required: true
type: string


#permissions:
# issues: write
# contents: write
# pull-requests: write

jobs:
release-module:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/release.sh ${{ github.event.inputs.module_path }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc

# Ignore release artifacts
/**/*/package.json
/**/*/package-lock.json
/**/*/node_modules
/**/*/LICENSE
4 changes: 4 additions & 0 deletions aptible/managed_endpoint/package.module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "aptible_managed_endpoint",
"description": "Managed HTTPS endpoint for Aptible."
}
23 changes: 23 additions & 0 deletions package.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "cfa-tofu-modules",
"private": true,
"repository": {
"type": "git",
"url": "[email protected]:codeforamerica/tofu-modules.git"
},
"devDependencies": {
"@semantic-release/github": "~11.0",
"semantic-release": "~24.1"
},
"release": {
"branches": [
"main",
"module-release"
]
},
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
52 changes: 52 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

ROOT_PATH="$(dirname "$0")/.."
MODULE_PATH="$1"

# Determine if a command exists on the current system.
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Attempt to install the jq package.
install_jq() {
echo 'Attempting to install jq...'

if command_exists brew; then
brew install jq
elif command_exists apt-get; then
sudo apt-get install -y jq
elif command_exists dnf; then
sudo dnf install -y jq
elif command_exists yum; then
sudo yum install -y jq
else
echo 'error: unable to determine package manager'
exit 1
fi
}

# Verify that jq is available on the system.
if ! command_exists jq
then
install_jq
fi

# Combine the package.json files.
jq -s ".[0] * .[1] | .repository.directory=\"${MODULE_PATH}\"" \
"${ROOT_PATH}/package.base.json" \
"${ROOT_PATH}/${MODULE_PATH}/package.module.json" \
> "${ROOT_PATH}/${MODULE_PATH}/package.json"

module_name=$(jq -r '.name' "${ROOT_PATH}/${MODULE_PATH}/package.json")

echo 'Installing dependencies...'
cp LICENSE "${MODULE_PATH}/."
cd "${MODULE_PATH}"
npm install

echo "Releasing module ${module_name}..."
npx semantic-release -t "${module_name}/\${version}"

echo 'Cleaning up...'
#rm -rf package.json package-lock.json LICENSE node_modules

0 comments on commit 88374fc

Please sign in to comment.