-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from khos2ow/enhance-release
build: overall improvements to release scripts
- Loading branch information
Showing
7 changed files
with
206 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright 2021 The terraform-docs Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o pipefail | ||
set -o errtrace | ||
|
||
NEW_VERSION=$1 | ||
TF_DOCS_VERSION=$2 | ||
|
||
PWD=$(cd "$(dirname "$0")" && pwd -P) | ||
|
||
if [ -z "${NEW_VERSION}" ]; then | ||
NEW_VERSION=$(grep "uses: terraform-docs/gh-actions" "${PWD}"/../../README.md | tr -s ' ' | uniq | cut -d"@" -f2) | ||
fi | ||
if [ -z "${NEW_VERSION}" ]; then | ||
echo "Usage: pre-release.sh <NEW_VERSION> <TF_DOCS_VERSION>" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${TF_DOCS_VERSION}" ]; then | ||
TF_DOCS_VERSION=$(grep "FROM quay.io/terraform-docs/terraform-docs" "${PWD}"/../Dockerfile | tr -s ' ' | uniq | cut -d":" -f2) | ||
fi | ||
if [ -z "${TF_DOCS_VERSION}" ]; then | ||
echo "Usage: pre-release.sh <NEW_VERSION> <TF_DOCS_VERSION>" | ||
exit 1 | ||
fi | ||
|
||
# Update README | ||
VERSION=v${NEW_VERSION//v/} TERRAFORM_DOCS_VERSION=v${TF_DOCS_VERSION//v/} \ | ||
gomplate \ | ||
-d action="${PWD}"/../../action.yml \ | ||
-f "${PWD}"/../../.github/templates/README.tpl \ | ||
-o "${PWD}"/../../README.md | ||
|
||
# Update Dockerfile | ||
sed -i -E "s|FROM quay.io/terraform-docs/terraform-docs:(.*)|FROM quay.io/terraform-docs/terraform-docs:${TF_DOCS_VERSION//v/}|g" "${PWD}"/../../Dockerfile | ||
|
||
# Update action.yml | ||
sed -i -E "s|docker://quay.io/terraform-docs/gh-actions:(.*)\"|docker://quay.io/terraform-docs/gh-actions:${NEW_VERSION//v/}\"|g" "${PWD}"/../../action.yml | ||
|
||
if [ "$(git status --porcelain | grep -c 'M README.md')" -eq 1 ]; then | ||
echo "Modified: README.md" | ||
fi | ||
if [ "$(git status --porcelain | grep -c 'M Dockerfile')" -eq 1 ]; then | ||
echo "Modified: Dockerfile" | ||
fi | ||
if [ "$(git status --porcelain | grep -c 'M action.yml')" -eq 1 ]; then | ||
echo "Modified: action.yml" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: update-terraform-docs | ||
run-name: update terraform-docs version | ||
|
||
on: | ||
repository_dispatch: | ||
types: [trigger-workflow] | ||
workflow_dispatch: | ||
inputs: | ||
release-version: | ||
description: "terraform-docs new release version" | ||
required: true | ||
type: string | ||
|
||
env: | ||
GOMPLATE_VERSION: "v3.8.0" | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
token: ${{ secrets.COMMITTER_TOKEN }} | ||
|
||
- name: Install gomplate | ||
run: | | ||
sudo curl -sSLo /usr/local/bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/${{ env.GOMPLATE_VERSION }}/gomplate_linux-amd64 | ||
sudo chmod 755 /usr/local/bin/gomplate | ||
- name: Get variables | ||
run: | | ||
if [ -n "${{ github.event.client_payload.release-version }}" ]; then | ||
release_version="${{ github.event.client_payload.release-version }}" | ||
else | ||
release_version="${{ inputs.release-version }}" | ||
fi | ||
echo "release_version=${release_version//v/}" >> "$GITHUB_ENV" | ||
- name: Bump to terraform-docs v${{ env.release_version }} | ||
run: | | ||
./.github/scripts/prepare-release.sh "" ${{ env.release_version }} | ||
- name: Push terraform-docs v${{ env.release_version }} Changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.COMMITTER_TOKEN }} | ||
with: | ||
file_pattern: "README.md Dockerfile" | ||
commit_message: "chore: bump terraform-docs to v${{ env.release_version }}" | ||
commit_user_name: terraform-docs-bot | ||
commit_user_email: bot@terraform-docs.io | ||
commit_author: "terraform-docs-bot <bot@terraform-docs.io>" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters