Skip to content

Commit

Permalink
Simplify repository input format in GitReleaseManager
Browse files Browse the repository at this point in the history
Updated the repository input to require a single string in the format 'owner/repo' for various action configurations and examples. Removed the separate 'owner' input parameter and adjusted relevant test cases and function implementations accordingly to parse repository information from the provided format.
  • Loading branch information
arturcic committed Dec 10, 2024
1 parent bc8cf5c commit fc6efe4
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 79 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ jobs:
uses: ./gitreleasemanager/create
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repository: actions
repository: ${{ github.repository }}
milestone: "v${{ steps.gitversion.outputs.majorMinorPatch }}"
name: "v${{ steps.gitversion.outputs.majorMinorPatch }}"
isPreRelease: 'false'
Expand All @@ -67,16 +66,14 @@ jobs:
uses: ./gitreleasemanager/addasset
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repository: actions
repository: ${{ github.repository }}
milestone: "v${{ steps.gitversion.outputs.majorMinorPatch }}"
assets: ${{ steps.publish-azure.outputs.vsix }}
- name: Close Release
uses: ./gitreleasemanager/close
with:
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repository: actions
repository: ${{ github.repository }}
milestone: "v${{ steps.gitversion.outputs.majorMinorPatch }}"
- name: Get tags
id: get-tags
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/azure/gitreleasemanager/addasset.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
- task: gitreleasemanager/addasset@3.1.1
inputs:
token: '$(GITHUB_TOKEN)'
owner: 'someOwner'
repository: 'someRepo'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
assets: |
src/test.txt
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/azure/gitreleasemanager/close.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- task: gitreleasemanager/close@3.1.1
inputs:
token: '$(GITHUB_TOKEN)'
owner: 'someOwner'
repository: 'someRepo'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/azure/gitreleasemanager/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
displayName: Create release with GitReleaseManager
inputs:
token: $(GITHUB_TOKEN)
owner: 'someOwner'
repository: 'someRepo'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
name: 'v0.1.0'
assets: |
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/azure/gitreleasemanager/discard.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- task: gitreleasemanager/discard@3.1.1
inputs:
token: '$(GITHUB_TOKEN)'
owner: 'someOwner'
repository: 'someRepo'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/azure/gitreleasemanager/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- task: gitreleasemanager/open@3.1.1
inputs:
token: '$(GITHUB_TOKEN)'
owner: 'someOwner'
repository: 'someRepo'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/azure/gitreleasemanager/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- task: gitreleasemanager/publish@3.1.1
inputs:
token: '$(GITHUB_TOKEN)'
owner: 'someOwner'
repository: 'someRepo'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/github/gitreleasemanager/addasset.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
name: Add asset to a release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: 'someOwner'
repository: 'someRepository'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
assets: |
src/test.txt
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/github/gitreleasemanager/close.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
name: Close release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: 'someOwner'
repository: 'someRepository'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/github/gitreleasemanager/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
name: Create release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: 'someOwner'
repository: 'someRepository'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
name: 'v0.1.0'
assets: |
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/github/gitreleasemanager/discard.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
name: Discard release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: 'someOwner'
repository: 'someRepository'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/github/gitreleasemanager/open.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
name: Open release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: 'someOwner'
repository: 'someRepository'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
3 changes: 1 addition & 2 deletions docs/examples/github/gitreleasemanager/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
name: Publish release with GitReleaseManager
with:
token: ${{ secrets.GITHUB_TOKEN }}
owner: 'someOwner'
repository: 'someRepository'
repository: 'someOwner/someRepo'
milestone: '0.1.0'
```
6 changes: 1 addition & 5 deletions gitreleasemanager/addasset/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ runs:
using: node20
main: main.mjs
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
description: The name of the repository in the format owner/repo
required: true
default: ''
token:
Expand Down
6 changes: 1 addition & 5 deletions gitreleasemanager/close/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ runs:
using: node20
main: main.mjs
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
description: The name of the repository in the format owner/repo
required: true
default: ''
token:
Expand Down
6 changes: 1 addition & 5 deletions gitreleasemanager/create/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ runs:
using: node20
main: main.mjs
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
description: The name of the repository in the format owner/repo
required: true
default: ''
token:
Expand Down
6 changes: 1 addition & 5 deletions gitreleasemanager/discard/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ runs:
using: node20
main: main.mjs
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
description: The name of the repository in the format owner/repo
required: true
default: ''
token:
Expand Down
6 changes: 1 addition & 5 deletions gitreleasemanager/open/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ runs:
using: node20
main: main.mjs
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
description: The name of the repository in the format owner/repo
required: true
default: ''
token:
Expand Down
6 changes: 1 addition & 5 deletions gitreleasemanager/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ runs:
using: node20
main: main.mjs
inputs:
owner:
description: The owner of the repository
required: true
default: ''
repository:
description: The name of the repository
description: The name of the repository in the format owner/repo
required: true
default: ''
token:
Expand Down
18 changes: 6 additions & 12 deletions src/__tests__/tools/gitreleasemanager/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { expectValidSettings } from '../common/utils'
describe('GitReleaseManager settings', () => {
it('should return GitReleaseManagerCreateSettings', () => {
const settings: CreateSettings = {
repository: 'repo',
owner: 'owner',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'path',
milestone: 'milestone',
Expand All @@ -42,8 +41,7 @@ describe('GitReleaseManager settings', () => {

it('should return OpenSettings', () => {
const settings: OpenSettings = {
repository: 'repo',
owner: 'owner',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'path',
milestone: 'milestone',
Expand All @@ -63,8 +61,7 @@ describe('GitReleaseManager settings', () => {

it('should return GitReleaseManagerCloseSettings', () => {
const settings: CloseSettings = {
repository: 'repo',
owner: 'owner',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'path',
milestone: 'milestone',
Expand All @@ -84,8 +81,7 @@ describe('GitReleaseManager settings', () => {

it('should return DiscardSettings', () => {
const settings: DiscardSettings = {
repository: 'repo',
owner: 'owner',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'path',
milestone: 'milestone',
Expand All @@ -105,8 +101,7 @@ describe('GitReleaseManager settings', () => {

it('should return PublishSettings', () => {
const settings: PublishSettings = {
repository: 'repo',
owner: 'owner',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'path',
milestone: 'milestone',
Expand All @@ -126,8 +121,7 @@ describe('GitReleaseManager settings', () => {

it('should return AddAssetSettings', () => {
const settings: AddAssetSettings = {
repository: 'repo',
owner: 'owner',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'path',
milestone: 'milestone',
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/tools/gitreleasemanager/tool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ describe('GitReleaseManagerTool', () => {

describe('getArguments', () => {
const commonSettings = {
owner: 'owner',
repository: 'repo',
repository: 'owner/repo',
token: 'token',
targetDirectory: 'targetDirectory',
logFilePath: './logFilePath'
Expand Down
1 change: 0 additions & 1 deletion src/tools/gitreleasemanager/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export type Commands = 'setup' | 'addasset' | 'close' | 'create' | 'discard' | '

export type CommonSettings = {
repository: string
owner: string
token: string
targetDirectory: string
milestone: string
Expand Down
2 changes: 0 additions & 2 deletions src/tools/gitreleasemanager/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ export class GitReleaseManagerSettingsProvider extends SettingsProvider implemen

getCommonSettings(): CommonSettings {
const milestone = this.buildAgent.getInput<CommonSettings>('milestone')
const owner = this.buildAgent.getInput<CommonSettings>('owner')
const repository = this.buildAgent.getInput<CommonSettings>('repository')
const token = this.buildAgent.getInput<CommonSettings>('token')
const targetDirectory = this.buildAgent.getInput<CommonSettings>('targetDirectory')
const logFilePath = this.buildAgent.getInput<CommonSettings>('logFilePath')

return {
owner,
repository,
token,
targetDirectory,
Expand Down
5 changes: 3 additions & 2 deletions src/tools/gitreleasemanager/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ export class GitReleaseManagerTool extends DotnetTool {
protected async getCommonArguments(settings: CommonSettings): Promise<string[]> {
const args: string[] = []

args.push('--owner', settings.owner)
args.push('--repository', settings.repository)
const [owner, repository] = settings.repository.split('/') // this is the github repository
args.push('--owner', owner)
args.push('--repository', repository)
args.push('--token', settings.token)

settings.targetDirectory = await this.getRepoDir(settings)
Expand Down

0 comments on commit fc6efe4

Please sign in to comment.