Skip to content

Commit

Permalink
Merge pull request #31 from ynput/refactor-release-workflow-structure
Browse files Browse the repository at this point in the history
Refactor release workflow structure
  • Loading branch information
philnewm authored Nov 26, 2024
2 parents 4b5863f + f2fabe7 commit 45c069b
Show file tree
Hide file tree
Showing 13 changed files with 760 additions and 567 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/build_from_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Build from Branch

on:
workflow_call:
inputs:
repo:
type: string
required: true
branch_name:
type: string
required: true
default: "main"
project_name:
type: string
required: true
artifact_name:
type: string
required: true
next_version:
type: string
required: false
secrets:
gh_token:
required: true
gh_user:
required: true
gh_email:
required: true

outputs:
artifact_file:
description: List of unique labels
value: ${{ jobs.build-from-branch.outputs.artifact_file }}

env:
GH_TOKEN: ${{ secrets.gh_token }}
OUTPUT_DIR: "artifact"
NEXT_VERSION: "${{ inputs.next_version }}"
PROJECT_NAME: "${{ inputs.project_name }}"
ARTIFACT_NAME: "${{ inputs.artifact_name }}"

jobs:
build-from-branch:
runs-on: ubuntu-latest

outputs:
artifact_file: ${{ steps.create-artifact.outputs.file_name }}

steps:
- name: ⬇️ Checkout ${{ inputs.branch_name }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch_name }}
fetch-depth: 0
submodules: true

- name: Update package.py version to ${{ env.NEXT_VERSION }}
run: |
sed -i "s/^version = \".*\"/version = \"${{ env.NEXT_VERSION }}\"/" package.py
sed -i "s/^name = \".*\"/name = \"${{ env.PROJECT_NAME }}\"/" package.py
- name: Create package artifacts
id: create-artifact
run: |
python create_package.py --output ${{ env.OUTPUT_DIR }}
echo "file_name=${{ env.PROJECT_NAME }}-${{ env.NEXT_VERSION }}.zip" >> $GITHUB_OUTPUT
- name: 🔑 Set Bot Authentication
run: |
git config --global user.name "${{ secrets.gh_user }}"
git config --global user.email "${{ secrets.gh_email }}"
- name: Add changed files from ${{ vars.MAIN_BRANCH }}
# INFO wont work in ayon-addon-action testing for initial release
# INFO due to no present changes at this point in time
# WARNING This will offset the tag by one commit if generated artifact is the only change cause it's excluded
run: |
git add . -- ':!${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}'
if git diff --cached --exit-code > /dev/null; then
echo "No changes to commit"
else
git commit -m "[Automated] Add generated package files from ${{ vars.MAIN_BRANCH }}"
fi
git tag -a ${{ env.NEXT_VERSION }} -m "[Automated] Release version ${{ env.NEXT_VERSION }}"
- name: 🔏 Push to protected ${{ vars.MAIN_BRANCH }} branch
uses: CasperWA/[email protected]
with:
token: ${{ env.GH_TOKEN }}
branch: ${{ vars.MAIN_BRANCH }}
tags: true
unprotect_reviews: false

- name: 🔼 Upload package zip artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
${{ env.OUTPUT_DIR }}/${{ steps.create-artifact.outputs.file_name }}
Loading

0 comments on commit 45c069b

Please sign in to comment.