Skip to content

WIP: Bj release cleanup #31

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
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
14 changes: 10 additions & 4 deletions .github/workflows/build.yml → .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Build
name: Package Library

on:
push:
# Avoid duplicate builds on PRs.
branches:
- main
branches: [main]
pull_request:
permissions:
contents: read
Expand Down Expand Up @@ -33,3 +32,10 @@ jobs:
- run: npm run lint
- run: npm run test
- run: npm run build
- name: Upload artifacts for release
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, 'release')
uses: actions/upload-artifact@v4
with:
name: heroku-applink-nodejs
path: dist/
retention-days: 90
83 changes: 83 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish to NPM and Change Management

on:
workflow_run:
workflows: ["Create Github Tag and Release"]
types:
- completed
branches:
- main

permissions:
contents: write
actions: read
id-token: write

jobs:
check_for_moratorium:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
environment: change_management
steps:
- uses: actions/checkout@v4
- env:
TPS_API_TOKEN: ${{ secrets.TPS_API_TOKEN_PARAM }}
run: ./scripts/release/tps-check-lock heroku-applink-nodejs ${{ github.sha }}

publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs: check_for_moratorium
runs-on: ubuntu-latest
environment: change_management
permissions:
contents: write
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: Get latest build workflow run
id: get_workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get the most recent successful build workflow run for this commit
RUN_ID=$(gh run list --workflow "test-lint-build.yml" --branch main --json databaseId,conclusion,headSha --jq ".[] | select(.headSha == \"${{ github.sha }}\" and .conclusion == \"success\") | .databaseId" | head -n 1)

if [ -z "$RUN_ID" ]; then
echo "No successful build found for commit ${{ github.sha }}"
exit 1
fi

echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
echo "Found build workflow run: $RUN_ID"

- name: Download build artifacts
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p dist
gh run download ${{ steps.get_workflow.outputs.run_id }} --name heroku-applink-nodejs --dir dist/

- name: Install dependencies
run: npm ci

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_RELEASE_AUTOMATION_TOKEN }}

- name: Publish To Change Management
env:
ACTOR_EMAIL: ${{ secrets.TPS_API_RELEASE_ACTOR_EMAIL }}
TPS_API_TOKEN: ${{ secrets.TPS_API_TOKEN_PARAM }}
# Failure to record the release should not fail the workflow for now.
continue-on-error: true
run: ./scripts/release/tps-record-release heroku-applink-nodejs ${{ github.sha }}
74 changes: 74 additions & 0 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Create Github Tag and Release

on:
workflow_run:
workflows: ["Package Library"]
types:
- completed
branches:
- main

permissions:
contents: write
actions: read
id-token: write

jobs:
push-git-tag:
if: ${{ github.event.workflow_run.conclusion == 'success' && contains(github.event.workflow_run.head_commit.message, 'Merge pull request') && contains(github.event.workflow_run.head_commit.message, 'release-v') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifact using GitHub CLI
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p dist
gh run download ${{ github.event.workflow_run.id }} --name release-artifacts-main --dir dist/

- name: Extract version from branch name
id: version
run: |
VERSION=$(echo "${{ github.event.workflow_run.head_commit.message }}" | grep -o 'release-v[0-9]\+\.[0-9]\+\.[0-9]\+' | sed 's/release-v//')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"

- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"

- name: Create and push Github tag
run: |
echo "Creating tag v${{ steps.version.outputs.version }}"
git tag -s "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
echo "Pushing tag to origin..."
git push origin "v${{ steps.version.outputs.version }}"
echo "Verifying tag was pushed:"
git ls-remote --tags origin "v${{ steps.version.outputs.version }}"

- name: Get tag name
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Using tag: $TAG"

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_tag.outputs.tag }}
generate_release_notes: true
files: |
dist/**/*
package.json
README.md
CHANGELOG.md
LICENSE.txt
SECURITY.md
TERMS_OF_USE.md
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ tsconfig.tsbuildinfo
.DS_Store
src/**/*.js
src/**/*.js.map

# Salesforce
.codegenie/

# Heroku TPS TEMP
tpsGetLock_response.txt
tpsRecordRelease_response.txt
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.3.4-ea] - 2024-03-21

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- Update CODEOWNERS
### Changes

## [0.1.0-ea] - 2024-08-12
### Features
* Initial release ([c5d593f](https://github.com/heroku/heroku-applink-nodejs/commit/c5d593fa3c0f37607239e3ded7c2c24d7354383c))

- Initial
44 changes: 0 additions & 44 deletions bin/bump-version.js

This file was deleted.

9 changes: 0 additions & 9 deletions bin/publish.sh

This file was deleted.

93 changes: 93 additions & 0 deletions docs/release-workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Release Workflow

This document outlines the process for releasing new versions of the Heroku Salesforce SDK Node.js package.

## Release Process

### 1. Creating a Release Branch

There are two ways to start a release:

#### Option 1: GitHub Actions Workflow
1. Go to the "Actions" tab in GitHub
2. Select "Draft Release Branch" workflow
3. Click "Run workflow"
4. Select the type of version bump (major, minor, patch)

#### Option 2: Command Line Script
Run the draft-release script locally:
```bash
./scripts/release/draft-release [<newversion> | major | minor | patch]
```

This will:
1. Run `npm version` with the provided version type
* `npm version` will update the version in package.json and commit that change.
2. Create a release branch named `release-v{version}`
3. Update `CHANGELOG.md` with all commits since the last tag
4. Create a draft PR from the release branch to main

### 2. Testing and Building

When a PR is created or updated, the following GitHub Actions workflows run automatically:

1. `package.yml`:
- Runs on pushes to main and PRs
- Lints the code
- Runs tests
- Builds the package
- Uploads build artifacts for release branches

### 3. Creating a Release Tag

After the PR is merged to main and tests pass:
1. The `create-tag.yml` workflow runs automatically
2. Creates a git tag with the version number
3. Pushes the tag to the repository

### 4. Publishing the Release

When a new tag is pushed:
1. The `publish.yml` workflow runs automatically
2. Publishes the package to npm
3. Creates a GitHub release with the changelog

## Workflow Files

- `.github/workflows/package.yml`: Runs tests and builds on PRs and pushes
- `.github/workflows/create-tag.yml`: Creates git tags after successful merges
- `.github/workflows/publish.yml`: Publishes to npm and creates GitHub releases

## Requirements

- GitHub Actions permissions for:
- Contents (read/write)
- Packages (read/write)
- Environment secrets:
- `NPM_TOKEN`: For publishing to npm

## Best Practices

1. **Version Naming**:
- Use semantic versioning (MAJOR.MINOR.PATCH)
- Major: Breaking changes
- Minor: New features, no breaking changes
- Patch: Bug fixes, no breaking changes

2. **Changelog**:
- Review the generated changelog in the PR
- Ensure all significant changes are documented
- Follow conventional commit format for better changelog generation

3. **Testing**:
- Ensure all tests pass before merging
- Test the package locally before releasing

## Rolling Back

If issues are found in a production release:
1. Create a new patch release to fix the issue
2. Follow the standard release process
3. Document the fix in the changelog

Note: We follow a "fix forward" approach rather than reverting releases to maintain a clear audit trail and versioning history.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
"format:check": "prettier --check .",
"format:write": "prettier --write .",
"prepack": "tsc -b --clean && tsc -b --force",
"bump": "node bin/bump-version.js",
"release": "bin/publish.sh",
"docs": "typedoc"
},
"files": [
Expand Down
Loading