-
Notifications
You must be signed in to change notification settings - Fork 23
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
Automatic release and versioning #197
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
75377e9
US852217 - ALKS TFP - Automate CI/CD pipeline with Github Actions
DevOpsDave dc8a7a6
Adding comments for helpfulness and documenting what required release…
DevOpsDave 6c90db8
Using 'release --clean' over 'release --rm-dist' to address deprecato…
DevOpsDave ee65fd6
Removed attempt at setting up local testing and the gitignore entries…
DevOpsDave 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 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,23 @@ | ||
# For this check to pass you must have a release label on your PR. | ||
# valid labels are: release/patch, release/minor, release/major, release/skip | ||
name: Check For Release Label | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
check_for_release_label: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Get release label | ||
uses: actions-ecosystem/[email protected] | ||
id: release-label | ||
|
||
- run: echo "Release level is ${{ steps.release-label.outputs.level }}" | ||
|
||
- name: Fail if label does not exist, or skip if release/skip label exists | ||
if: ${{ ( ! contains(github.event.pull_request.labels.*.name, 'release/skip') ) && ( steps.release-label.outputs.level == null ) }} | ||
run: echo "Please label your PR with a release label" && exit 1 |
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,86 @@ | ||
# This GitHub action can publish assets for release when a tag is created. | ||
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). | ||
# | ||
# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your | ||
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` | ||
# secret. If you would rather own your own GPG handling, please fork this action | ||
# or use an alternative one for key handling. | ||
# | ||
# You will need to pass the `--batch` flag to `gpg` in your signing step | ||
# in `goreleaser` to indicate this is being used in a non-interactive mode. | ||
# | ||
name: release-auto2 | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
auto-release: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.pull_request.merged == true }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Unshallow fetch | ||
run: git fetch --prune --unshallow | ||
|
||
- name: Get release label | ||
uses: actions-ecosystem/action-release-label@v1 | ||
id: release-label | ||
if: ${{ github.event.pull_request.merged == true }} | ||
|
||
- name: Get latest tag | ||
uses: actions-ecosystem/action-get-latest-tag@v1 | ||
id: get-latest-tag | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
|
||
- run: | | ||
echo "Latest tag: ${{ steps.get-latest-tag.outputs.tag }}" | ||
echo "Release level: ${{ steps.release-label.outputs.level }}" | ||
|
||
- name: Bump the version | ||
uses: actions-ecosystem/action-bump-semver@v1 | ||
id: bump-semver | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
with: | ||
current_version: ${{ steps.get-latest-tag.outputs.tag }} | ||
level: ${{ steps.release-label.outputs.level }} | ||
|
||
- run: | | ||
echo "New version: ${{ steps.bump-semver.outputs.new_version }}" | ||
|
||
- name: Push new tag | ||
uses: actions-ecosystem/action-push-tag@v1 | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
with: | ||
tag: ${{ steps.bump-semver.outputs.new_version }} | ||
message: '${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}' | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
with: | ||
go-version: 1.18.x | ||
|
||
- name: Import GPG key | ||
id: import_gpg | ||
uses: paultyng/[email protected] | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
PASSPHRASE: ${{ secrets.PASSPHRASE }} | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
if: ${{ steps.release-label.outputs.level != null }} | ||
with: | ||
version: latest | ||
args: release --clean | ||
env: | ||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on this? What testing framework outside of
go test
? This may be of benefit to the team if you found a nice tool.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was put in because I was attempting to run GH actions locally, and ultimately test without actually running in the repo and making changes. It was a passing try and I didn't spend too much time on it. Ultimately it was easier to simply model out the behavior I wanted in a separate repo, got it to work the way I wanted and then copy pasta'ed to this one.
Here is the content of package-json and test.js if you are curious:
If you are curious where I modeled the actions I did it here, should be 0 Cox properties in this public repo:
https://github.com/DevOpsDave/testing-github-actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LumaC0 I removed the testing stuff from my repo and took out the .gitignore entiries that hid the artifacts since nothing was actually being done with it. Neater now.