Skip to content

Commit

Permalink
fix(build): add release assets PR creation (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
autero1 authored Feb 23, 2024
1 parent 3a76193 commit 24242c3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 29 deletions.
85 changes: 56 additions & 29 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,67 @@
on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

workflow_dispatch:
name: release-please

env:
ACTION_NAME: action-terragrunt
jobs:
release-please:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Remove old lib
run: |
rm -Rf ./lib
mkdir ./lib
- name: Install Dependencies
run: npm ci
- name: Build Project
run: npm run build
- name: Commit ./lib/index.js
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add ./lib/index.js
git commit -m "chore(release): Add build assets" || echo "No changes to commit"
git push --force origin main
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: install
run: npm ci
- name: build
run: npm run build
- name: commit
run: |-
set -e
# get current commit hash
CURRENT_HASH=$(git rev-parse HEAD)
# get last commit hash of last build lib
LAST_BUILD_HASH=$(git log --author=google-github-actions-bot -1 --pretty=format:"%H")
DIFF=""
# build and commit lib if diff
git config --global user.name "actions-bot"
git config user.email 'github-actions-bot@google.com'
git add lib/
git diff-index --quiet HEAD || git commit -m "chore: build lib ${ACTION_NAME}"
# if last commit hash of last build lib was found, get logs of commits in btw for PR body
if [ -z "$LAST_BUILD_HASH" ]
then
echo "Unable to find last commit by bot, skipping diff gen"
else
DIFF=$(git log ${LAST_BUILD_HASH}...${CURRENT_HASH} --oneline)
echo $DIFF
fi
# set env vars
echo "CURRENT_HASH=${CURRENT_HASH}" >> $GITHUB_ENV
echo "LAST_BUILD_HASH=${LAST_BUILD_HASH}" >> $GITHUB_ENV
echo 'DIFF<<EOF' >> $GITHUB_ENV
echo "${DIFF}" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create PR with lib
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Build lib
author: "actions-bot <github-actions-bot@google.com>"
title: "chore: build lib"
body: |
Build lib PR
${{env.DIFF}}
labels: automated pr
branch: create-pull-request/build-lib
delete-branch: true
release-please-release:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: google-github-actions/release-please-action@v4
id: release
with:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/test-action release-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test Action Release Version

on:
workflow_dispatch:

jobs:
test-release-version:
runs-on: "ubuntu-22.04"
steps:
- uses: autero1/action-terragrunt@v3
with:
terragrunt-version: 0.55.0
- name: Validate
run: terragrunt --version
- uses: autero1/action-terragrunt@v3
with:
terragrunt-version: latest
- name: Validate
run: terragrunt --version

0 comments on commit 24242c3

Please sign in to comment.