Skip to content

Commit

Permalink
split into multiple workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtharriger committed May 19, 2024
1 parent 25a0465 commit 77b7076
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 148 deletions.
152 changes: 4 additions & 148 deletions .github/workflows/ci-build-release.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,21 @@
name: CI Build and Release
name: Build

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
check-last-commit-author:
if: ${{ github.event.repository.fork == false }}
runs-on: ubuntu-latest
outputs:
author: ${{ steps.get_author.outputs.author }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get last commit author
id: get_author
run: echo "author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT

release-version:
needs: check-last-commit-author
if: needs.check-last-commit-author.outputs.author != 'clj-mergetool Release Bot'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Clojure CLI and Babashka
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 'latest'
bb: 'latest'

- name: Configure Git
run: |
git config --global user.name 'clj-mergetool Release Bot'
git config --global user.email 'kurtharriger@gmail.com'
- name: Run Release Version Task
run: clojure -T:build release-version

- name: Upload updated code
uses: actions/upload-artifact@v4
with:
name: updated-code
path: .
if-no-files-found: error

- name: Upload release notes
uses: actions/upload-artifact@v4
with:
name: release-notes
path: RELEASE_NOTES.md
if-no-files-found: error

build:
needs: release-version
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [amd64, arm64]

runs-on: ${{ matrix.os }}

steps:
- name: Download updated code
uses: actions/download-artifact@v4
with:
name: updated-code
- name: Checkout code
uses: actions/checkout@v4

- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
Expand All @@ -103,84 +40,3 @@ jobs:
name: clj-mergetool-${{ matrix.os }}-${{ matrix.arch }}
path: target/clj-mergetool${{ matrix.os == 'windows-latest' && '.exe' || '' }}
if-no-files-found: error

push-changes:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download updated code
uses: actions/download-artifact@v4
with:
name: updated-code

- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://oauth2:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin main --tags
release:
if: github.ref == 'refs/heads/main'
needs: push-changes
runs-on: ubuntu-latest

steps:
- name: Download build artifacts for Linux amd64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-ubuntu-latest-amd64
path: target/clj-mergetool-linux-amd64

- name: Download build artifacts for Linux arm64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-ubuntu-latest-arm64
path: target/clj-mergetool-linux-arm64

- name: Download build artifacts for Windows amd64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-windows-latest-amd64
path: target/clj-mergetool-windows-amd64.exe

- name: Download build artifacts for Windows arm64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-windows-latest-arm64
path: target/clj-mergetool-windows-arm64.exe

- name: Download build artifacts for macOS amd64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-macos-latest-amd64
path: target/clj-mergetool-macos-amd64

- name: Download build artifacts for macOS arm64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-macos-latest-arm64
path: target/clj-mergetool-macos-arm64

- name: Download release notes
uses: actions/download-artifact@v4
with:
name: release-notes
path: RELEASE_NOTES.md

- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTES.md
files: |
target/clj-mergetool-linux-amd64
target/clj-mergetool-linux-arm64
target/clj-mergetool-windows-amd64.exe
target/clj-mergetool-windows-arm64.exe
target/clj-mergetool-macos-amd64
target/clj-mergetool-macos-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120 changes: 120 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Publish Release

on:
push:
branches:
- main

jobs:
check-last-commit-author:
runs-on: ubuntu-latest
outputs:
author: ${{ steps.get_author.outputs.author }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get last commit author
id: get_author
run: echo "author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT

build:
if: needs.check-last-commit-author.outputs.author != 'clj-mergetool Release Bot'
needs: check-last-commit-author
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
arch: [amd64, arm64]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: Install Clojure CLI and Babashka
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 'latest'
bb: 'latest'

- name: Run CI Task
run: clojure -T:build ci

- name: Archive build artifact
uses: actions/upload-artifact@v4
with:
name: clj-mergetool-${{ matrix.os }}-${{ matrix.arch }}
path: target/clj-mergetool${{ matrix.os == 'windows-latest' && '.exe' || '' }}

release:
if: needs.check-last-commit-author.outputs.author == 'clj-mergetool Release Bot'
needs: check-last-commit-author
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download build artifacts for Linux amd64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-ubuntu-latest-amd64
path: target/clj-mergetool-linux-amd64

- name: Download build artifacts for Linux arm64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-ubuntu-latest-arm64
path: target/clj-mergetool-linux-arm64

- name: Download build artifacts for Windows amd64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-windows-latest-amd64
path: target/clj-mergetool-windows-amd64.exe

- name: Download build artifacts for Windows arm64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-windows-latest-arm64
path: target/clj-mergetool-windows-arm64.exe

- name: Download build artifacts for macOS amd64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-macos-latest-amd64
path: target/clj-mergetool-macos-amd64

- name: Download build artifacts for macOS arm64
uses: actions/download-artifact@v4
with:
name: clj-mergetool-macos-latest-arm64
path: target/clj-mergetool-macos-arm64

- name: Download release notes
uses: actions/download-artifact@v4
with:
name: release-notes
path: RELEASE_NOTES.md

- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTES.md
files: |
target/clj-mergetool-linux-amd64
target/clj-mergetool-linux-arm64
target/clj-mergetool-windows-amd64.exe
target/clj-mergetool-windows-arm64.exe
target/clj-mergetool-macos-amd64
target/clj-mergetool-macos-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Generate Release Commit

on:
workflow_dispatch:

jobs:
release-version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Clojure CLI and Babashka
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: 'latest'
bb: 'latest'

- name: Configure Git
run: |
git config --global user.name 'clj-mergetool Release Bot'
git config --global user.email 'kurtharriger@gmail.com'
- name: Run Release Version Task
run: clojure -T:build release-version

- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout -b release-notes-branch
git add .
git commit -m "Generate release notes"
git push origin release-notes-branch
gh pr create --title "Release Notes Update" --body "This PR contains the updated release notes" --base main --head release-notes-branch

0 comments on commit 77b7076

Please sign in to comment.