-
Notifications
You must be signed in to change notification settings - Fork 0
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
First commits #1
Open
jsf9k
wants to merge
27
commits into
develop
Choose a base branch
from
first-commits
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
06e0b8a
Add versioning
jsf9k 2c6216e
Revert link
jsf9k f4d983b
Add example action that simply prints a notice annotation
jsf9k 0f95a68
Update README.md boilerplate from upstream
jsf9k 26a14dc
Add a link to the GitHub documentation on composite actions
jsf9k e1054d8
Remove unwanted word
jsf9k 23bc7e5
Use lowercase when referring to GitHub actions
jsf9k 4156a58
Add a workflow to create major and major-minor version tags upon release
jsf9k 66b3953
Add published as a release type that should trigger this workflow
jsf9k d270c90
Bump version from 0.0.1 to 1.0.0
jsf9k 81665bd
Bump version from 1.0.0 to 1.0.0-rc.1
jsf9k 63e96c3
Remove github.ref_type checks
jsf9k d2f145d
Bump version from 1.0.0-rc.1 to 1.0.0-rc.2
jsf9k 3284849
Fix typo
jsf9k 447a29e
Bump version from 1.0.0-rc.2 to 1.0.0-rc.3
jsf9k d3e1d18
Only attempt to delete tags if they actually exist
jsf9k 3fc68f0
Bump version from 1.0.0-rc.3 to 1.0.0-rc.4
jsf9k 9fd843f
Set default shell options
jsf9k a8fae25
Fix bug in shell logic
jsf9k 911c3b7
Bump version from 1.0.0-rc.4 to 1.0.0-rc.5
jsf9k d7f1317
Create tags individually
jsf9k b8837c0
Bump version from 1.0.0-rc.5 to 1.0.0-rc.6
jsf9k e2ad30f
Bump version from 1.0.0-rc.6 to 1.0.0-rc.7
jsf9k fa725b9
Remove prereleased as a release type that should trigger this workflow
jsf9k 666579b
Bump version from 1.0.0-rc.7 to 1.0.0-rc.8
jsf9k db7df1b
Add missing map key
jsf9k 84dc3e9
Remove period from end of single-line comment
jsf9k 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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
name: release | ||
|
||
on: | ||
release: | ||
types: | ||
- released | ||
|
||
# Set a default shell for any run steps. The `-Eueo pipefail` sets | ||
# errtrace, nounset, errexit, and pipefail. The `-x` will print all | ||
# commands as they are run. Please see the GitHub Actions | ||
# documentation for more information: | ||
# https://docs.github.com/en/actions/using-jobs/setting-default-values-for-jobs | ||
defaults: | ||
run: | ||
shell: bash -Eueo pipefail -x {0} | ||
|
||
jobs: | ||
diagnostics: | ||
name: Run diagnostics | ||
# This job does not need any permissions | ||
permissions: {} | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Note that a duplicate of this step must be added at the top of | ||
# each job. | ||
- uses: GitHubSecurityLab/actions-permissions/monitor@v1 | ||
with: | ||
# Uses the organization variable unless overridden | ||
config: ${{ vars.ACTIONS_PERMISSIONS_CONFIG }} | ||
# Note that a duplicate of this step must be added at the top of | ||
# each job. | ||
- id: harden-runner | ||
name: Harden the runner | ||
uses: step-security/harden-runner@v2 | ||
with: | ||
egress-policy: audit | ||
- id: github-status | ||
name: Check GitHub status | ||
uses: crazy-max/ghaction-github-status@v4 | ||
- id: dump-context | ||
name: Dump context | ||
uses: crazy-max/ghaction-dump-context@v2 | ||
release: | ||
needs: | ||
- diagnostics | ||
permissions: | ||
# We need write permission to move tags | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: GitHubSecurityLab/actions-permissions/monitor@v1 | ||
with: | ||
# Uses the organization variable unless overridden | ||
config: ${{ vars.ACTIONS_PERMISSIONS_CONFIG }} | ||
- id: harden-runner | ||
name: Harden the runner | ||
uses: step-security/harden-runner@v2 | ||
with: | ||
egress-policy: audit | ||
- id: extract-semver-parts | ||
name: Extract semver parts | ||
uses: zyactions/semver@v1 | ||
with: | ||
# This input consists of a newline-separated list of version | ||
# prefixes, so in the interest of future expansion we go | ||
# ahead and use the YAML multiline literal style indicator. | ||
prefixes: | | ||
v | ||
- id: checkout-code | ||
name: Checkout the code | ||
uses: actions/checkout@v4 | ||
- id: move-tags | ||
# Just in case... | ||
if: ${{ steps.extract-semver-parts.outputs.valid == 'true' }} | ||
name: Move tags | ||
run: | | ||
major_tag=v${{ steps.extract-semver-parts.outputs.major }} | ||
major_minor_tag=${major_tag}.${{ steps.extract-semver-parts.outputs.minor }} | ||
# Delete old tags remotely, if they exist | ||
git ls-remote --exit-code --tags origin ${major_tag} \ | ||
&& git push origin --delete ${major_tag} | ||
git ls-remote --exit-code --tags origin ${major_minor_tag} \ | ||
&& git push origin --delete ${major_minor_tag} | ||
# Create new tags locally | ||
git tag ${major_tag} | ||
git tag ${major_minor_tag} | ||
# Push up new tags | ||
git push origin ${major_tag} ${major_minor_tag} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
author: Cybersecurity and Infrastructure Security Agency | ||
branding: | ||
color: blue | ||
icon: help-circle | ||
description: Skeleton GitHub composite action. | ||
name: Skeleton | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- id: my-id | ||
name: Say hello | ||
run: "echo ::notice:: Hello, world!" | ||
shell: bash |
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,172 @@ | ||
#!/usr/bin/env bash | ||
|
||
# bump-version [--push] [--label LABEL] (major | minor | patch | prerelease | build | finalize | show) | ||
# bump-version --list-files | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
# Stores the canonical version for the project. | ||
VERSION_FILE=version.txt | ||
# Files that should be updated with the new version. | ||
VERSION_FILES=("$VERSION_FILE") | ||
|
||
USAGE=$( | ||
cat << END_OF_LINE | ||
Update the version of the project. | ||
|
||
Usage: | ||
${0##*/} [--push] [--label LABEL] (major | minor | patch | prerelease | build | finalize | show) | ||
${0##*/} --list-files | ||
${0##*/} (-h | --help) | ||
|
||
Options: | ||
-h | --help Show this message. | ||
--push Perform a \`git push\` after updating the version. | ||
--label LABEL Specify the label to use when updating the build or prerelease version. | ||
--list-files List the files that will be updated when the version is bumped. | ||
END_OF_LINE | ||
) | ||
|
||
old_version=$(< "$VERSION_FILE") | ||
# Comment out periods so they are interpreted as periods and don't | ||
# just match any character | ||
old_version_regex=${old_version//\./\\\.} | ||
new_version="$old_version" | ||
|
||
bump_part="" | ||
label="" | ||
commit_prefix="Bump" | ||
with_push=false | ||
commands_with_label=("build" "prerelease") | ||
commands_with_prerelease=("major" "minor" "patch") | ||
with_prerelease=false | ||
|
||
####################################### | ||
# Display an error message, the help information, and exit with a non-zero status. | ||
# Arguments: | ||
# Error message. | ||
####################################### | ||
function invalid_option() { | ||
echo "$1" | ||
echo "$USAGE" | ||
exit 1 | ||
} | ||
|
||
####################################### | ||
# Bump the version using the provided command. | ||
# Arguments: | ||
# The version to bump. | ||
# The command to bump the version. | ||
# Returns: | ||
# The new version. | ||
####################################### | ||
function bump_version() { | ||
local temp_version | ||
temp_version=$(python -c "import semver; print(semver.parse_version_info('$1').${2})") | ||
echo "$temp_version" | ||
} | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "$USAGE" | ||
exit 1 | ||
else | ||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
--push) | ||
if [ "$with_push" = true ]; then | ||
invalid_option "Push has already been set." | ||
fi | ||
|
||
with_push=true | ||
shift | ||
;; | ||
--label) | ||
if [ -n "$label" ]; then | ||
invalid_option "Label has already been set." | ||
fi | ||
|
||
label="$2" | ||
shift 2 | ||
;; | ||
build | finalize | major | minor | patch) | ||
if [ -n "$bump_part" ]; then | ||
invalid_option "Only one version part should be bumped at a time." | ||
fi | ||
|
||
bump_part="$1" | ||
shift | ||
;; | ||
prerelease) | ||
with_prerelease=true | ||
shift | ||
;; | ||
show) | ||
echo "$old_version" | ||
exit 0 | ||
;; | ||
-h | --help) | ||
echo "$USAGE" | ||
exit 0 | ||
;; | ||
--list-files) | ||
printf '%s\n' "${VERSION_FILES[@]}" | ||
exit 0 | ||
;; | ||
*) | ||
invalid_option "Invalid option: $1" | ||
;; | ||
esac | ||
done | ||
fi | ||
|
||
if [ -n "$label" ] && [ "$with_prerelease" = false ] && [[ ! " ${commands_with_label[*]} " =~ [[:space:]]${bump_part}[[:space:]] ]]; then | ||
invalid_option "Setting the label is only allowed for the following commands: ${commands_with_label[*]}" | ||
fi | ||
|
||
if [ "$with_prerelease" = true ] && [ -n "$bump_part" ] && [[ ! " ${commands_with_prerelease[*]} " =~ [[:space:]]${bump_part}[[:space:]] ]]; then | ||
invalid_option "Changing the prerelease is only allowed in conjunction with the following commands: ${commands_with_prerelease[*]}" | ||
fi | ||
|
||
label_option="" | ||
if [ -n "$label" ]; then | ||
label_option="token='$label'" | ||
fi | ||
|
||
if [ -n "$bump_part" ]; then | ||
if [ "$bump_part" = "finalize" ]; then | ||
commit_prefix="Finalize" | ||
bump_command="finalize_version()" | ||
elif [ "$bump_part" = "build" ]; then | ||
bump_command="bump_${bump_part}($label_option)" | ||
else | ||
bump_command="bump_${bump_part}()" | ||
fi | ||
new_version=$(bump_version "$old_version" "$bump_command") | ||
echo Changing version from "$old_version" to "$new_version" | ||
fi | ||
|
||
if [ "$with_prerelease" = true ]; then | ||
bump_command="bump_prerelease($label_option)" | ||
temp_version=$(bump_version "$new_version" "$bump_command") | ||
echo Changing version from "$new_version" to "$temp_version" | ||
new_version="$temp_version" | ||
fi | ||
|
||
tmp_file=/tmp/version.$$ | ||
for version_file in "${VERSION_FILES[@]}"; do | ||
if [ ! -f "$version_file" ]; then | ||
echo Missing expected file: "$version_file" | ||
exit 1 | ||
fi | ||
sed "s/$old_version_regex/$new_version/" "$version_file" > $tmp_file | ||
mv $tmp_file "$version_file" | ||
done | ||
|
||
git add "${VERSION_FILES[@]}" | ||
git commit --message "$commit_prefix version from $old_version to $new_version" | ||
|
||
if [ "$with_push" = true ]; then | ||
git push | ||
fi |
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,2 +1,4 @@ | ||
# The bump-version script requires at least version 3 of semver. | ||
semver>=3 | ||
setuptools | ||
wheel |
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 @@ | ||
1.0.0-rc.8 |
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.
Another consistency one.
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 have been trying to add an
id
andname
for every step since I started working with the GH Actions jazz recently. What is your reasoning for not doing that?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 don't have a reason to not do that, but we should start with cisagov/skeleton-generic and push it down in a consistent manner. This is specifically because we haven't done it with uses of actions/checkout.
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.
My intent was to take care of this inconsistency when I'm able to start using reusable workflows via cisagov/github-actions-workflows. In the meantime I'd like to continue using
name
andid
in the new code I am creating.