Skip to content

Commit

Permalink
Merge pull request #1608 from oliviermgx/with_TimeTag
Browse files Browse the repository at this point in the history
publication tag = timestamp ms
  • Loading branch information
lexoyo authored Jun 27, 2024
2 parents 44f2023 + 30c9f3c commit 8dcf258
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/ts/plugins/server/GitlabHostingConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,13 @@ export default class GitlabHostingConnector extends GitlabConnector implements H
return `${projectUrl}/-/jobs/`
}

async createTag(session: GitlabSession, websiteId: WebsiteId, job: JobData, { startJob, jobSuccess, jobError }: JobManager): Promise<string | null> {
async createTag(session: GitlabSession, websiteId: WebsiteId, job: PublicationJobData, { startJob, jobSuccess, jobError }: JobManager): Promise<string | null> {
const projectId = websiteId // Assuming websiteId corresponds to GitLab project ID

// Fetch the latest tag and determine the new tag
let newTag, tags
try {
job.message = 'Fetching latest tag and commits...'
// Fetch the latest tag
tags = await this.callApi(session, `api/v4/projects/${projectId}/repository/tags`, 'GET')
const latestTag = tags[0]?.name || 'v0.0.0'
const [major, minor, patch] = latestTag.slice(1).split('.').map(Number)
newTag = `v${major}.${minor}.${patch + 1}`
} catch (error) {
console.error('Error during fetching latest tag:', error.message)
jobError(job.jobId, `Failed to fetch latest tag: ${error.message}`)
return null
}

const newTag = '_silex_' + Date.now()
// Create a new tag
try {
job.message = `Creating new tag ${newTag}...`
job.logs[0].push(job.message)
await this.callApi(session, `api/v4/projects/${projectId}/repository/tags`, 'POST', {
tag_name: newTag,
ref: 'main',
Expand Down

0 comments on commit 8dcf258

Please sign in to comment.