-
Notifications
You must be signed in to change notification settings - Fork 0
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 #31 from ynput/refactor-release-workflow-structure
Refactor release workflow structure
- Loading branch information
Showing
13 changed files
with
760 additions
and
567 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,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 }} |
Oops, something went wrong.