-
Notifications
You must be signed in to change notification settings - Fork 5
Release Workflows #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,82 @@ | ||
# GitHub Releasing Workflow | ||
name: GitHub - Release | ||
|
||
on: | ||
workflow_distach: | ||
inputs: | ||
bump: | ||
type: choice | ||
description: "The type of version bump to perform" | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
workflow_call: | ||
inputs: | ||
version: | ||
description: "The version to release" | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release-next: | ||
runs-on: ubuntu-latest | ||
# If the workflow was triggered by workflow_dispatch | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v3 | ||
|
||
- name: "Patch Release Me" | ||
uses: 42ByteLabs/patch-release-me@0.3.0 | ||
with: | ||
mode: ${{ github.event.inputs.bump }} | ||
|
||
- name: "Create Release" | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ github.token }} | ||
commit-message: "[chore]: Create release for ${{ github.event.inputs.version }}" | ||
title: "[chore]: Create release for ${{ github.event.inputs.version }}" | ||
branch: chore-release-${{ github.event.inputs.version }} | ||
base: ${{ github.event.before }} | ||
labels: version | ||
body: | | ||
This is an automated PR to create a new release. The release will be created once this PR is merged. | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
# If the workflow was triggered by a workflow call and the version is not null | ||
if: ${{ github.event_name == 'workflow_call' && github.event.inputs.version != null }} | ||
steps: | ||
# https://github.com/peter-murray/semver-data-action | ||
- name: Parse SemVer | ||
id: version | ||
uses: peter-murray/semver-action@v1 | ||
with: | ||
version: ${{ inputs.version }} | ||
|
||
# Tags :: ${Full}, v${Major}, v${Major}.${Minor}, v${Major}.${Minor}.${Patch} | ||
- name: "GitHub Release" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
|
||
git tag "${{ steps.version.outputs.version }}" --force | ||
git tag "v${{ steps.version.outputs.major }}" --force | ||
git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" --force | ||
git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" --force | ||
|
||
git push origin ${{ github.ref_name }} | ||
git push origin --tags --force | ||
|
||
gh release create --latest --generate-notes \ | ||
--title "v${{ steps.version.outputs.version }}" \ | ||
"${{ steps.version.outputs.version }}" | ||
|
This file contains hidden or 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 hidden or 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,45 @@ | ||
name: "Self - Release" | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
fetch-release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release: ${{ steps.version-changes.outputs.release }} | ||
version: ${{ steps.version-changes.outputs.version }} | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
|
||
- name: "Fetch Release" | ||
id: version-changes | ||
run: | | ||
set -e | ||
|
||
pip install yq | ||
|
||
current_version=$(cat .release.yml | yq -r ".version") | ||
released_version=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/:owner/:repo/releases/latest | jq -r ".tag_name") | ||
|
||
if [[ "$current_version" == "NA" || "$current_version" == "$released_version" ]]; then | ||
echo "No new release found" | ||
echo "release=false" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "New release found" | ||
echo "version=$current_version" >> "$GITHUB_OUTPUT" | ||
echo "release=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
|
||
release: | ||
uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.1.0 | ||
needs: [ fetch-release ] | ||
if: ${{ needs.fetch-release.outputs.release == 'true' }} | ||
secrets: inherit | ||
with: | ||
version: ${{ needs.fetch-release.outputs.version }} |
This file contains hidden or 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,11 @@ | ||
name: "reusable-workflows" | ||
version: "0.1.0" | ||
|
||
locations: | ||
- name: "Actions Versions" | ||
paths: | ||
- '.github/workflows/*.yml' | ||
- 'wiki/*.md' | ||
patterns: | ||
# Actions | ||
- 'advanced-security/reusable-workflows/.github/workflows/.*\.yml@v([0-9]\.[0-9]\.[0-9])' |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.