-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
442ddf5
commit 111b878
Showing
1 changed file
with
149 additions
and
0 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,149 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
type: | ||
type: string | ||
description: "The release type, must be stable, beta, or alpha." | ||
default: "alpha" | ||
staging: | ||
type: boolean | ||
description: "Whether the release should be simulated or not." | ||
default: false | ||
branch: | ||
type: string | ||
description: "The branch to release from." | ||
default: "main" | ||
branch_version: | ||
type: string | ||
description: "The branch on unifier-version to bump." | ||
default: "main" | ||
pre_release: | ||
type: boolean | ||
description: "Whether the release should be a pre-release or not." | ||
default: false | ||
environment: | ||
type: string | ||
description: "The environment to release to." | ||
default: "Alpha release" | ||
secrets: | ||
DEPLOY_KEY: | ||
required: true | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
validate-input: | ||
name: "Validate inputs" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
- name: Validate inputs | ||
run: "python3 ./scripts/validate.py ${{ inputs.type }} ${{ inputs.staging }}" | ||
|
||
create-release: | ||
name: "Create release" | ||
runs-on: ubuntu-latest | ||
needs: [validate-input, pylint] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ inputs.branch }} | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
- name: Get version | ||
run: | | ||
python3 ./scripts/get_version.py | ||
- name: Get release notes | ||
run: | | ||
{ | ||
echo 'NOTES<<EOF' | ||
python3 ./scripts/get_notes.py '${{ env.VERSION }}' | ||
echo EOF | ||
} >> $GITHUB_ENV | ||
- name: Create GitHub release | ||
uses: ncipollo/[email protected] | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
name: ${{ env.RAW_VERSION }} | ||
tag: ${{ env.VERSION }} | ||
prerelease: ${{ inputs.pre_release }} | ||
body: ${{ env.NOTES }} | ||
commit: ${{ inputs.branch }} | ||
draft: ${{ inputs.staging }} | ||
skipIfReleaseExists: true | ||
publish-release: | ||
name: "Publish release" | ||
runs-on: ubuntu-latest | ||
needs: [create-release] | ||
environment: ${{ inputs.environment }} | ||
if: ${{ inputs.staging == false }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: 'UnifierHQ/unifier-version' | ||
ref: ${{ inputs.branch_version }} | ||
token: ${{ secrets.DEPLOY_KEY }} | ||
- name: Download Unifier | ||
run: | | ||
git clone --branch ${{ inputs.branch }} https://github.com/UnifierHQ/unifier | ||
- name: Set up Git config | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "<>" | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
- name: Bump version | ||
run: | | ||
python3 ./scripts/bump.py | ||
- name: Delete Unifier | ||
run: | | ||
rm -rf ./unifier | ||
- name: Push to repository | ||
run: | | ||
git add . | ||
git commit -m "Version bump for release" | ||
git push | ||
publish-release-staging: | ||
name: "Simulate release" | ||
runs-on: ubuntu-latest | ||
needs: [ create-release ] | ||
environment: ${{ inputs.environment }} | ||
if: ${{ inputs.staging == true }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: 'UnifierHQ/unifier-version' | ||
ref: ${{ inputs.branch_version }} | ||
- name: Download Unifier | ||
run: | | ||
git clone --branch ${{ inputs.branch }} https://github.com/UnifierHQ/unifier | ||
- name: Set up Git config | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "<>" | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
- name: Bump version | ||
run: | | ||
python3 ./scripts/bump.py | ||
- name: Delete Unifier | ||
run: | | ||
rm -rf ./unifier |