Skip to content

Commit a3036ae

Browse files
authored
Merge pull request #36 from advanced-security/workflow-releases
Release Workflows
2 parents a74484f + 2750903 commit a3036ae

12 files changed

+153
-15
lines changed

.github/workflows/dependency-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ jobs:
3838
echo "No local configuration file found"
3939
echo "Using configuration file from advanced-security/reusable-workflows repository"
4040
41-
echo "config=advanced-security/reusable-workflows/.github/dependency-review.yml@main" >> $GITHUB_STATE
41+
echo "config=advanced-security/reusable-workflows/.github/dependency-review.yml@v0.1.0" >> $GITHUB_STATE
4242
4343
fi
4444
4545
- name: 'Dependency Review'
4646
uses: actions/dependency-review-action@v4
4747
with:
4848
# this value can also be hardcoded to a remote repository
49-
# Example: advanced-security/reusable-workflows/.github/dependency-review.yml@main
49+
# Example: advanced-security/reusable-workflows/.github/dependency-review.yml@v0.1.0
5050
config-file: ${{ steps.config.outputs.config }}
5151
comment-summary-in-pr: "always"

.github/workflows/python-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
fi
5858
5959
github-release:
60-
uses: advanced-security/reusable-workflows/.github/workflows/release.yml@main
60+
uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.1.0
6161
needs: [ version-changes ]
6262
if: ${{ needs.version-changes.outputs.release == 'true' }}
6363
secrets: inherit

.github/workflows/python.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ on:
2626
jobs:
2727
# Run the tests on all supported versions of Python
2828
testing:
29-
uses: advanced-security/reusable-workflows/.github/workflows/python-testing.yml@main
29+
uses: advanced-security/reusable-workflows/.github/workflows/python-testing.yml@v0.1.0
3030
secrets: inherit
3131
with:
3232
versions: ${{ inputs.versions }}
3333

3434
# Run linters on the codebase
3535
linting:
36-
uses: advanced-security/reusable-workflows/.github/workflows/python-linting.yml@main
36+
uses: advanced-security/reusable-workflows/.github/workflows/python-linting.yml@v0.1.0
3737
needs: [ testing ]
3838
secrets: inherit
3939
with:
4040
versions: ${{ inputs.versions }}
4141

4242
# Vendor the dependencies into the repository if needed
4343
vendoring:
44-
uses: advanced-security/reusable-workflows/.github/workflows/python-vendor.yml@main
44+
uses: advanced-security/reusable-workflows/.github/workflows/python-vendor.yml@v0.1.0
4545
needs: [ testing, linting ]
4646
if: ${{ inputs.vendor == 'true' }}
4747
secrets: inherit
@@ -51,7 +51,7 @@ jobs:
5151

5252
# Release a new version of the package
5353
release:
54-
uses: advanced-security/reusable-workflows/.github/workflows/python-release.yml@main
54+
uses: advanced-security/reusable-workflows/.github/workflows/python-release.yml@v0.1.0
5555
needs: [ testing, linting ]
5656
secrets: inherit
5757
with:

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# GitHub Releasing Workflow
2+
name: GitHub - Release
3+
4+
on:
5+
workflow_distach:
6+
inputs:
7+
bump:
8+
type: choice
9+
description: "The type of version bump to perform"
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
workflow_call:
16+
inputs:
17+
version:
18+
description: "The version to release"
19+
required: true
20+
type: string
21+
22+
permissions:
23+
contents: write
24+
25+
jobs:
26+
release-next:
27+
runs-on: ubuntu-latest
28+
# If the workflow was triggered by workflow_dispatch
29+
if: ${{ github.event_name == 'workflow_dispatch' }}
30+
steps:
31+
- name: "Checkout"
32+
uses: actions/checkout@v3
33+
34+
- name: "Patch Release Me"
35+
uses: 42ByteLabs/patch-release-me@0.3.0
36+
with:
37+
mode: ${{ github.event.inputs.bump }}
38+
39+
- name: "Create Release"
40+
uses: peter-evans/create-pull-request@v6
41+
with:
42+
token: ${{ github.token }}
43+
commit-message: "[chore]: Create release for ${{ github.event.inputs.version }}"
44+
title: "[chore]: Create release for ${{ github.event.inputs.version }}"
45+
branch: chore-release-${{ github.event.inputs.version }}
46+
base: ${{ github.event.before }}
47+
labels: version
48+
body: |
49+
This is an automated PR to create a new release. The release will be created once this PR is merged.
50+
51+
release:
52+
runs-on: ubuntu-latest
53+
# If the workflow was triggered by a workflow call and the version is not null
54+
if: ${{ github.event_name == 'workflow_call' && github.event.inputs.version != null }}
55+
steps:
56+
# https://github.com/peter-murray/semver-data-action
57+
- name: Parse SemVer
58+
id: version
59+
uses: peter-murray/semver-action@v1
60+
with:
61+
version: ${{ inputs.version }}
62+
63+
# Tags :: ${Full}, v${Major}, v${Major}.${Minor}, v${Major}.${Minor}.${Patch}
64+
- name: "GitHub Release"
65+
env:
66+
GH_TOKEN: ${{ github.token }}
67+
run: |
68+
git config user.name github-actions
69+
git config user.email github-actions@github.com
70+
71+
git tag "${{ steps.version.outputs.version }}" --force
72+
git tag "v${{ steps.version.outputs.major }}" --force
73+
git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" --force
74+
git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" --force
75+
76+
git push origin ${{ github.ref_name }}
77+
git push origin --tags --force
78+
79+
gh release create --latest --generate-notes \
80+
--title "v${{ steps.version.outputs.version }}" \
81+
"${{ steps.version.outputs.version }}"
82+

.github/workflows/self-dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ permissions:
1919

2020
jobs:
2121
dependency-review:
22-
uses: advanced-security/reusable-workflows/.github/workflows/dependency-review.yml@main
22+
uses: advanced-security/reusable-workflows/.github/workflows/dependency-review.yml@v0.1.0
2323
secrets: inherit

.github/workflows/self-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Self - Release"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
fetch-release:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
release: ${{ steps.version-changes.outputs.release }}
15+
version: ${{ steps.version-changes.outputs.version }}
16+
steps:
17+
- name: "Checkout"
18+
uses: actions/checkout@v4
19+
20+
- name: "Fetch Release"
21+
id: version-changes
22+
run: |
23+
set -e
24+
25+
pip install yq
26+
27+
current_version=$(cat .release.yml | yq -r ".version")
28+
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")
29+
30+
if [[ "$current_version" == "NA" || "$current_version" == "$released_version" ]]; then
31+
echo "No new release found"
32+
echo "release=false" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "New release found"
35+
echo "version=$current_version" >> "$GITHUB_OUTPUT"
36+
echo "release=true" >> "$GITHUB_OUTPUT"
37+
fi
38+
39+
release:
40+
uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.1.0
41+
needs: [ fetch-release ]
42+
if: ${{ needs.fetch-release.outputs.release == 'true' }}
43+
secrets: inherit
44+
with:
45+
version: ${{ needs.fetch-release.outputs.version }}

.release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "reusable-workflows"
2+
version: "0.1.0"
3+
4+
locations:
5+
- name: "Actions Versions"
6+
paths:
7+
- '.github/workflows/*.yml'
8+
- 'wiki/*.md'
9+
patterns:
10+
# Actions
11+
- 'advanced-security/reusable-workflows/.github/workflows/.*\.yml@v([0-9]\.[0-9]\.[0-9])'

wiki/Build-Container.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This workflow does the following:
1515
**Simple:**
1616

1717
```yaml
18-
uses: advanced-security/reusable-workflows/.github/workflows/container.yml@main
18+
uses: advanced-security/reusable-workflows/.github/workflows/container.yml@v0.1.0
1919
secrets: inherit
2020
with:
2121
# This is used for tagging the container image.
@@ -26,7 +26,7 @@ with:
2626
**With Settings:**
2727
2828
```yaml
29-
uses: advanced-security/reusable-workflows/.github/workflows/container.yml@main
29+
uses: advanced-security/reusable-workflows/.github/workflows/container.yml@v0.1.0
3030
secrets: inherit
3131
with:
3232
# This is used for tagging the container image

wiki/Build-Python.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ The Action will try to determine how to install, build, test, and lint your proj
1515
**Simple:**
1616

1717
```yaml
18-
uses: advanced-security/reusable-workflows/.github/workflows/python-build.yml@main
18+
uses: advanced-security/reusable-workflows/.github/workflows/python.yml@v0.1.0
1919
```
2020
2121
**With Settings:**
2222
2323
```yaml
24-
uses: advanced-security/reusable-workflows/.github/workflows/python-build.yml@main
24+
uses: advanced-security/reusable-workflows/.github/workflows/python-build.yml@v0.1.0
2525
with:
2626
install: true # Install dependencies (default is true)
2727
build: false # Build the project

wiki/Linting-Markdown.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ Lint markdown files in your repository.
99
**Simple:**
1010

1111
```yaml
12-
uses: advanced-security/reusable-workflows/.github/workflows/markdown-lint.yml@main
12+
uses: advanced-security/reusable-workflows/.github/workflows/markdown-lint.yml@v0.1.0
1313
secrets: inherit
1414
```

0 commit comments

Comments
 (0)