Skip to content

Commit

Permalink
Allow specifying last commit used
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Castle <[email protected]>
  • Loading branch information
Kas-tle committed Nov 12, 2023
1 parent 95bf169 commit b3f32ba
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
branch: ${{ github.head_ref || github.ref_name }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- id: hash
run: echo ::set-output name=hash::$(git rev-parse HEAD)
- name: Make release
id: release
uses: ./
Expand All @@ -39,6 +42,7 @@ jobs:
dist/index.js
appID: ${{ secrets.RELEASE_APP_ID }}
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
lastCommit: ${{ steps.hash.outputs.hash }}

upload-logs:
name: Upload Logs
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Data about the previous release for each branch is stored under the `RELEASEACTI
| `ghApiUrl` | The GitHub API URL to use. Defaults to the api. plus the repo domain if not specified. | `auto` | `false` |
| `ghReleaseNotes` | Whether or not to let GitHub auto-generate its release notes. Defaults to false if not specified. | `false` | `false` |
| `includeReleaseInfo` | Whether or not to include the asset hashes in a release.json file. Defaults to true if not specified. | `true` | `false` |
| `lastCommit` | The last commit hash to use for the release. Defaults to the commit that triggered the workflow if not specified. | `auto` | `false` |
| `latestRelease` | Whether or not the release should be marked as the latest release. Defaults to auto if not specified, which will be true unless this is a pre-release. | `auto` | `false` |
| `preRelease` | Whether or not the release is a pre-release. Inferred by the branch if not specified. | `auto` | `false` |
| `releaseBody` | A file containing the body of the release. Defaults to the commit changelog if not specified. | `auto` | `false` |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
description: 'Whether or not to include the asset hashes in a release.json file. Defaults to true if not specified.'
required: false
default: 'true'
lastCommit:
description: 'The last commit hash to use for the release. Defaults to the commit that triggered the workflow if not specified.'
required: false
default: 'auto'
latestRelease:
description: 'Whether or not the release should be marked as the latest release. Defaults to auto if not specified, which will be true unless this is a pre-release.'
required: false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "base-release-action",
"version": "1.0.0",
"version": "1.0.1",
"description": "An action to create incremented releases in a similar style to Jenkins",
"repository": "https://github.com/Kas-tle/base-release-action.git",
"author": "Joshua Castle <[email protected]",
Expand Down
5 changes: 1 addition & 4 deletions src/action/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,21 @@ async function getTag(repoData: Repo, prevRelease: PreviousRelease): Promise<Inp
async function getChanges(api: OctokitApi, prevRelease: PreviousRelease, repoData: Repo): Promise<Inputs.Change[]> {
const { branch, defaultBranch } = repoData;
let firstCommit = '';
let lastCommit = '';
let lastCommit = core.getInput('lastCommit') === 'auto' ? process.env.GITHUB_SHA! : core.getInput('lastCommit');

if (prevRelease.commit == null) {
if (branch === defaultBranch) {
firstCommit = `${process.env.GITHUB_SHA!}^`;
lastCommit = process.env.GITHUB_SHA!;
} else {
const compareReponse = await api.rest.repos.compareCommits({ owner: repoData.owner, repo: repoData.repo, base: defaultBranch, head: branch });
try {
firstCommit = `${compareReponse.data.commits[0].sha}^`;
} catch (error) {
firstCommit = `${process.env.GITHUB_SHA!}^`;
}
lastCommit = process.env.GITHUB_SHA!;
}
} else {
firstCommit = prevRelease.commit;
lastCommit = process.env.GITHUB_SHA!;
}

const changes: Inputs.Change[] = [];
Expand Down

0 comments on commit b3f32ba

Please sign in to comment.