-
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.
[feature] Release Actions Support für Repositories mit mehreren Proje…
…kten. ORG-254
- Loading branch information
1 parent
b73d6bb
commit 39711b0
Showing
7 changed files
with
343 additions
and
171 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
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,43 +1,41 @@ | ||
name: Release Actions - Deploy build to OneDrive | ||
name: Release Actions - Deploy build to Fileserver | ||
on: | ||
workflow_call: | ||
inputs: | ||
artifact-name: | ||
type: string | ||
required: true | ||
artifact-file-name: | ||
type: string | ||
required: true | ||
projects-folder: | ||
type: string | ||
required: true | ||
project-name: | ||
type: string | ||
required: true | ||
file-extension: | ||
version: | ||
type: string | ||
required: true | ||
jobs: | ||
deploy-onedrive: | ||
name: Deploy build to OneDrive | ||
runs-on: [self-hosted, windows, onedrive] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download artifact | ||
id: download-artifact | ||
uses: actions/download-artifact@v3 | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact-name }} | ||
- name: Read project version | ||
id: version | ||
run: ("version=" + (Get-Content VERSION).replace(".", "_")) | Out-File -FilePath $env:GITHUB_OUTPUT -Append | ||
- name: Get Artifact Infos | ||
id: artifact | ||
run: | | ||
$artifact = (Get-ChildItem -Path "${{ steps.download-artifact.outputs.download-path }}")[0] | ||
("path=" + $artifact.FullName) | Out-File -FilePath $env:GITHUB_OUTPUT -Append | ||
("extension=" + $artifact.Extension) | Out-File -FilePath $env:GITHUB_OUTPUT -Append | ||
- name: Deploy | ||
shell: cmd | ||
run: | | ||
setlocal EnableDelayedExpansion | ||
set "SOURCE=${{ steps.download-artifact.outputs.download-path }}\${{ inputs.artifact-file-name }}" | ||
set "SOURCE=${{ steps.artifact.outputs.path }}" | ||
echo Source file: !SOURCE! | ||
set "DEST=%OneDriveCommercial%\F&E\Projekte\${{ inputs.projects-folder }}\${{ inputs.project-name }}\bin\${{ inputs.project-name }}_${{ steps.version.outputs.version }}${{ inputs.file-extension }}" | ||
set "DEST=%OneDriveCommercial%\F&E\Projekte\${{ inputs.projects-folder }}\${{ inputs.project-name }}\bin\${{ inputs.project-name }}_${{ inputs.version }}${{ steps.artifact.outputs.extension }}" | ||
echo Destination file: !DEST! | ||
copy "!SOURCE!" "!DEST!" |
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,168 @@ | ||
name: Release Actions - Setup | ||
on: | ||
workflow_call: | ||
inputs: | ||
ci-scripts-ref: | ||
type: string | ||
required: false | ||
default: master | ||
check-template: | ||
type: boolean | ||
required: false | ||
default: true | ||
outputs: | ||
release-stage: | ||
description: "the current stage of the release process" | ||
value: ${{ jobs.release-context.outputs.release-stage }} | ||
deploy-mode: | ||
description: "'release' or 'development'" | ||
value: ${{ jobs.release-context.outputs.deploy-mode }} | ||
project-name: | ||
description: "project name" | ||
value: ${{ jobs.release-context.outputs.project-name }} | ||
project-id: | ||
description: "sub project id" | ||
value: ${{ jobs.release-context.outputs.project-id }} | ||
version: | ||
description: "the current project version" | ||
value: ${{ jobs.release-context.outputs.version }} | ||
version-file: | ||
description: "version file containing the current version" | ||
value: ${{ jobs.release-context.outputs.version-file }} | ||
|
||
jobs: | ||
release-context: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout ci-scripts repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: baltech-ag/ci-scripts | ||
ref: ${{ inputs.ci-scripts-ref }} | ||
path: ci-scripts | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Build Release Context | ||
id: context | ||
shell: pwsh | ||
run: | ||
echo '${{ toJSON(github) }}' # prints github-context for debugging purposes | ||
python ci-scripts/release_actions.py ` | ||
print-release-context ` | ||
--event="${{ github.event_name }}" ` | ||
--ref="${{ github.head_ref || github.ref }}" ` | ||
--repository-name="${{ github.event.repository.name }}" ` | ||
| Out-File -FilePath $env:GITHUB_OUTPUT | ||
Get-Content -Path $env:GITHUB_OUTPUT # prints output variables for debugging purposes | ||
- name: Check for latest template version | ||
if: ${{ inputs.check-template && steps.context.output.release-stage == 'branch-created' }} | ||
run: | | ||
expectedHash="${{ hashFiles('ci-scripts/templates/org-release-actions.yml') }}" | ||
actualHash="${{ hashFiles('.github/workflows/org-release-actions.yml') }}" | ||
if [[ "$expectedHash" != "$actualHash" ]]; then | ||
echo "::error::Workflow org-release-actions.yml is outdated." | ||
echo "::error::Please replace '.github/workflows/org-release-actions.yml' in this repository with 'templates/org-release-actions.yml' from the ci-scripts repository.' | ||
exit 1 | ||
fi | ||
outputs: | ||
release-stage: ${{ steps.context.outputs.release-stage }} | ||
deploy-mode: ${{ steps.context.outputs.deploy-mode }} | ||
project-name: ${{ steps.context.outputs.project-name }} | ||
project-id: ${{ steps.context.outputs.project-id }} | ||
version: ${{ steps.context.outputs.version }} | ||
version-file: ${{ steps.context.outputs.version-file }} | ||
tag: ${{ steps.context.outputs.tag }} | ||
base-branch: ${{ steps.context.outputs.base-branch }} | ||
|
||
create-pr: | ||
name: Create PR | ||
runs-on: ubuntu-24.04 | ||
needs: [release-context] | ||
if: needs.release-context.outputs.release-stage == 'branch-created' | ||
steps: | ||
- name: Generate a token | ||
id: generate-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.BALTECH_BOT_ID }} | ||
private-key: ${{ secrets.BALTECH_BOT_KEY }} | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ steps.generate-token.outputs.token }} | ||
- name: Configure git | ||
run: | | ||
git config user.name "${{ github.actor }}" | ||
git config user.email "${{ github.actor }}@github.com" | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install tox | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox==3.28.0 | ||
- name: Restore tox environment from cache | ||
id: tox-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: .tox | ||
key: ${{ runner.os }}-tox-${{ hashFiles('tox.ini') }}-${{ hashFiles('poetry.lock') }} | ||
- name: Prepare next Version | ||
run: | | ||
echo "Increasing version in ${{ needs.release-context.outputs.version-file }} to ${{ needs.release-context.outputs.version }}") | ||
echo "${{ needs.release-context.outputs.version }}" > ${{ needs.release-context.outputs.version-file }} | ||
if not args.project_id: | ||
tox -v -v -- apply-version | ||
else: | ||
tox -v -v -- apply-version --project-name="${{ needs.release-context.outputs.project-name }}" | ||
git add --all | ||
git commit -m"[release] ${{ needs.release-context.outputs.project-name }} ${{ needs.release-context.outputs.version }}" | ||
git push origin ${{ github.ref_name }} | ||
- name: Create PR for release branch | ||
run: | | ||
PR_TITLE="[release] ${{ needs.release-context.outputs.project-name }} ${{ needs.release-context.outputs.version }}" | ||
gh pr create --base ${{ needs.release-context.outputs.base-branch }} --head ${{ github.ref }} --title "$PR_TITLE" --body "" --assignee "${{ github.actor }}" | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
- name: Approve PR | ||
run: gh pr review ${{ github.ref_name }} --approve | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Merge PR | ||
run: gh pr merge ${{ github.ref_name }} --rebase --auto | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} | ||
- name: Cleanup | ||
if: always() | ||
run: rm -rf ci-scripts | ||
|
||
create-tag: | ||
name: Create tag | ||
runs-on: ubuntu-24.04 | ||
needs: [release-context] | ||
if: ${{ needs.release-context.outputs.release-stage == 'pr-merged' && github.event.pull_request.merged == true }} | ||
steps: | ||
- name: Generate a token | ||
id: generate-token | ||
uses: actions/create-github-app-token@v1 | ||
with: | ||
app-id: ${{ secrets.BALTECH_BOT_ID }} | ||
private-key: ${{ secrets.BALTECH_BOT_KEY }} | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ steps.generate-token.outputs.token }} | ||
- name: Configure git | ||
run: | | ||
git config user.name "${{ github.event.pusher.name }}" | ||
git config user.email "${{ github.event.pusher.email }}" | ||
- name: Create tag on release commit | ||
run: | | ||
git tag ${{ needs.release-context.outputs.tag }} | ||
git push origin ${{ needs.release-context.outputs.tag }} |
Oops, something went wrong.