-
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.
build: overall improvements to release scripts
Signed-off-by: Khosrow Moossavi <[email protected]>
- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,66 @@ | ||
name: release | ||
run-name: release v${{ github.event.inputs.version }} | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "gh-actions version to be released (without leading v)" | ||
required: true | ||
type: string | ||
|
||
env: | ||
GOMPLATE_VERSION: "v3.8.0" | ||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} | ||
|
||
jobs: | ||
release: | ||
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 -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/${{ env.GOMPLATE_VERSION }}/gomplate_linux-amd64 | ||
sudo chmod 755 /usr/local/bin/gomplate | ||
- name: Get variables | ||
run: | | ||
release_version="${{ inputs.version }}" | ||
echo "release_version=${release_version//v/}" >> "$GITHUB_ENV" | ||
- name: Prepare v${{ env.release_version }} Release | ||
run: | | ||
./.github/scripts/prepare-release.sh ${{ env.release_version }} | ||
- name: Push v${{ env.release_version }} Changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.COMMITTER_TOKEN }} | ||
with: | ||
file_pattern: "README.md action.yml" | ||
commit_message: "chore: prepare release v${{ env.release_version }}" | ||
commit_user_name: terraform-docs-bot | ||
commit_user_email: [email protected] | ||
commit_author: "terraform-docs-bot <[email protected]>" | ||
|
||
docker: | ||
runs-on: ubuntu-latest | ||
needs: [release] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
|
||
- name: Login to Docker | ||
uses: docker/login-action@v3 | ||
|
@@ -25,19 +73,30 @@ jobs: | |
- name: Build Docker image | ||
if: env.REGISTRY_USERNAME != '' | ||
run: | | ||
VERSION=$(echo ${{ github.event.release.tag_name }} | sed 's/v//') | ||
docker build --pull --tag quay.io/terraform-docs/gh-actions:"${VERSION}" . | ||
docker build --pull --tag quay.io/terraform-docs/gh-actions:${{ env.release_version }} . | ||
docker build --pull --tag quay.io/terraform-docs/gh-actions:latest . | ||
docker push quay.io/terraform-docs/gh-actions:"${VERSION}" | ||
docker push quay.io/terraform-docs/gh-actions:${{ env.release_version }} | ||
docker push quay.io/terraform-docs/gh-actions:latest | ||
update-tag: | ||
runs-on: ubuntu-latest | ||
needs: [release] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
token: ${{ secrets.COMMITTER_TOKEN }} | ||
|
||
- name: Cut v${{ env.release_version }} Release | ||
run: | | ||
git config --global user.name terraform-docs-bot | ||
git config --global user.email [email protected] | ||
git tag "v${{ env.release_version }}" | ||
git push origin "v${{ env.release_version }}" | ||
- run: | | ||
VERSION=$(echo ${{ github.event.release.tag_name }} | cut -d. -f1) | ||
git tag -f "${VERSION}" | ||
git push -f --tags | ||
VERSION=$(echo ${{ env.release_version }} | cut -d. -f1) | ||
git tag -f v${VERSION} | ||
git push -f v${VERSION} |
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: [email protected] | ||
commit_author: "terraform-docs-bot <[email protected]>" |
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