Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/test-composed-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
DEFAULT_PERSONAL_ACCESS_KEY: ${{ secrets.HUBSPOT_PERSONAL_ACCESS_KEY }}
DEFAULT_ACCOUNT_ID: ${{ secrets.HUBSPOT_ACCOUNT_ID }}
DEFAULT_PROFILE: "prod"
DEFAULT_CLI_VERSION: "7.9.0"
DEFAULT_CLI_VERSION: "7.11.7-experimental.0"

jobs:
deploy:
Expand All @@ -16,14 +16,17 @@ jobs:
uses: ./project-validate
with:
project_dir: ./.github/workflows/test-project
debug: true
- name: HubSpot Project Upload Action
id: upload-project-step
uses: ./project-upload
with:
project_dir: ./.github/workflows/test-project
debug: true
- name: HubSpot Project Deploy Action
if: ${{ steps.upload-project-step.outputs.build_id != '' }}
uses: ./project-deploy
with:
project_dir: ./.github/workflows/test-project
deploy_latest_build: true
debug: true
3 changes: 2 additions & 1 deletion .github/workflows/test-default-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:
DEFAULT_PERSONAL_ACCESS_KEY: ${{ secrets.HUBSPOT_PERSONAL_ACCESS_KEY }}
DEFAULT_ACCOUNT_ID: ${{ secrets.HUBSPOT_ACCOUNT_ID }}
DEFAULT_PROFILE: "prod"
DEFAULT_CLI_VERSION: "7.9.0"
DEFAULT_CLI_VERSION: "7.11.7-experimental.0"

jobs:
deploy:
Expand All @@ -16,3 +16,4 @@ jobs:
uses: ./
with:
project_dir: ./.github/workflows/test-project
debug: true
45 changes: 31 additions & 14 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,49 @@ This project uses semantic versioning with Git tags. Here's how to create a new

**IMPORTANT** Remember to update the references to the install cli action within the other actions

#### 1. Prepare for Release
## 1. Prepare for Release

Before creating a release, ensure:

- All changes are merged to the main branch
- Tests are passing
- Documentation is up to date
- You're on the main branch and it's up to date
- You're on the main branch, and it's up to date.

```bash
git checkout main
git pull origin main
```

#### 2. Create a Release Tag

### 1.a Determine what the new version will be
Use semantic versioning to determine the appropriate version number:

- **MAJOR** version for incompatible API changes
- **MINOR** version for backwards-compatible functionality additions
- **PATCH** version for backwards-compatible bug fixes

Create and push the tag:
### 1.b Update version references
Once you have determined what the new version will be, you will need to update any version references in the actions themselves. So create a branch and
update the version in the `uses` keys in both the .yml files and the examples in the README.md files.

They will look like this:

```yaml
uses: HubSpot/hubspot-project-actions/project-upload@version
```

Before you create the tag...
- Check out a new branch for the release
- Make sure to update any version references in the actions
- Commit your local changes
Once those all have been updated, open a PR to `main` and get it approved and merge it.

## 2. Create a Release Tag
After your PR to update the versions is merged get the latest main changes again.

```bash
git checkout main
git pull origin main
```

Then you can use the `npm run version` script to create a new version.

Use our scripts to handle versioning
```bash
# Show available commands
npm run version help
Expand All @@ -51,18 +64,22 @@ npm run version info
npm run version create <version> [message]
```

### Rollback a Release
### Delete the tag, if needed

If you need to rollback a release (use with caution):
If you need to delete the tag for some reason:

```bash
# Delete the tag locally
git tag -d v1.0.0
git tag -d vx.x.x

# Delete the tag from remote
git push origin --delete v1.0.0
git push origin --delete vx.x.x
```


## 3. Publish the release
Now that the tag exists, [create a release](https://github.com/HubSpot/hubspot-project-actions/releases/new) for the new version in the repo. Once this is created, it will publish the new version in the marketplace.

**Note:** Rolling back a release can cause issues for users who are already using that version. Only do this if absolutely necessary and communicate the change to users.

### Best Practices
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ inputs:
description: "Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment."
required: false
type: string
debug:
description: "Enable debug mode for HubSpot CLI commands. Passes --debug flag to all hs commands."
required: false
default: false
type: boolean
outputs:
build_id:
description: "The build ID of the created HubSpot project build"
Expand All @@ -48,6 +53,7 @@ runs:
account_id: ${{ inputs.account_id }}
cli_version: ${{ inputs.cli_version }}
profile: ${{ inputs.profile }}
debug: ${{ inputs.debug }}
- name: Upload HubSpot Project
id: upload-project-step
uses: HubSpot/hubspot-project-actions/[email protected]
Expand All @@ -57,4 +63,5 @@ runs:
account_id: ${{ inputs.account_id }}
cli_version: ${{ inputs.cli_version }}
profile: ${{ inputs.profile }}
debug: ${{ inputs.debug }}

3 changes: 2 additions & 1 deletion project-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ runs:
using: "composite"
steps:
- name: Install HubSpot CLI
uses: HubSpot/hubspot-project-actions/[email protected].1
uses: HubSpot/hubspot-project-actions/[email protected].0
with:
cli_version: ${{ inputs.cli_version }}
- name: Deploy a HubSpot project build
Expand All @@ -46,6 +46,7 @@ runs:
HUBSPOT_PERSONAL_ACCESS_KEY: ${{ inputs.personal_access_key || env.DEFAULT_PERSONAL_ACCESS_KEY }}
HUBSPOT_ACCOUNT_ID: ${{ inputs.account_id || env.DEFAULT_ACCOUNT_ID }}
HUBSPOT_PROFILE: ${{ inputs.profile || env.DEFAULT_PROFILE }}
HUBSPOT_DEBUG: ${{ inputs.debug }}
run: |
# Source shared utilities
. "$GITHUB_ACTION_PATH/../scripts/action-utils.sh"
Expand Down
6 changes: 6 additions & 0 deletions project-upload/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ inputs:
description: "Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment."
required: false
type: string
debug:
description: "Enable debug mode for HubSpot CLI commands. Passes --debug flag to all hs commands."
required: false
default: false
type: boolean
outputs:
build_id:
description: "The build ID of the created HubSpot project build"
Expand All @@ -40,6 +45,7 @@ runs:
HUBSPOT_PERSONAL_ACCESS_KEY: ${{ inputs.personal_access_key || env.DEFAULT_PERSONAL_ACCESS_KEY }}
HUBSPOT_ACCOUNT_ID: ${{ inputs.account_id || env.DEFAULT_ACCOUNT_ID }}
HUBSPOT_PROFILE: ${{ inputs.profile || env.DEFAULT_PROFILE }}
HUBSPOT_DEBUG: ${{ inputs.debug }}
run: |
# Source shared utilities
. "$GITHUB_ACTION_PATH/../scripts/action-utils.sh"
Expand Down
6 changes: 6 additions & 0 deletions project-validate/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ inputs:
description: "Profile to use for the HubSpot CLI. If not provided, will use DEFAULT_PROFILE from environment."
required: false
type: string
debug:
description: "Enable debug mode for HubSpot CLI commands. Passes --debug flag to all hs commands."
required: false
default: false
type: boolean
runs:
using: "composite"
steps:
Expand All @@ -35,6 +40,7 @@ runs:
HUBSPOT_PERSONAL_ACCESS_KEY: ${{ inputs.personal_access_key || env.DEFAULT_PERSONAL_ACCESS_KEY }}
HUBSPOT_ACCOUNT_ID: ${{ inputs.account_id || env.DEFAULT_ACCOUNT_ID }}
HUBSPOT_PROFILE: ${{ inputs.profile || env.DEFAULT_PROFILE }}
HUBSPOT_DEBUG: ${{ inputs.debug }}
run: |
# Source shared utilities
. "$GITHUB_ACTION_PATH/../scripts/action-utils.sh"
Expand Down
34 changes: 27 additions & 7 deletions scripts/action-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,35 @@ resolve_project_dir() {
# Sets PARSED_OUTPUT variable with the parsed JSON (if JSON parsing is enabled and successful)
# Returns the command's exit code
run_hs_command() {
local command="$1"
local command="$1 --debug"
local expect_json="${2:-false}"

# Run command and capture output
COMMAND_OUTPUT=$(eval "$command")
local exit_code=$?
# Ensure pipefail so we can read the real exit code when piping
set -o pipefail

# Use a temp file so we can both stream to console and capture full output
local tmp
tmp="$(mktemp)" || { echo "Error: failed to create temp file"; return 1; }

echo "BEFORE"
# Run the command, redirecting stderr to stdout, tee to temporary file so we can capture it,
# and capture the command's exit code via PIPESTATUS[0]
# Use bash -lc so shell features/expansions in $command behave as before
( /bin/bash -lc "$command" 2>&1 | tee -a "$tmp" )

local exit_code=${PIPESTATUS[0]}

echo "exit_code=$exit_code"

# Read the captured output
COMMAND_OUTPUT="$(cat "$tmp")"
rm -f "$tmp"


if [ $exit_code -ne 0 ]; then
echo "Error: Command failed with output:"
echo "Error: Command failed with exit code $exit_code and output:"
echo "$COMMAND_OUTPUT"
exit $exit_code
return $exit_code
fi

# Parse JSON if enabled
Expand All @@ -77,13 +95,15 @@ run_hs_command() {
return 0
else
echo "Error: Failed to parse JSON output: $COMMAND_OUTPUT"
exit 1
return 1
fi
fi

return 0
}



# Sets a GitHub Actions output from JSON, using the global PARSED_OUTPUT variable
# Automatically exits with code 1 if a required output is missing
# Arguments:
Expand Down
Loading