mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-09 19:27:04 +00:00
Compare commits
No commits in common. "b61723279775f6ff425884ce78baf158e1aa2357" and "b55cba293f90d1e564794a3ae1fbc470224eaef7" have entirely different histories.
b617232797
...
b55cba293f
21 changed files with 99 additions and 203 deletions
113
.github/renovate.json5
vendored
113
.github/renovate.json5
vendored
|
|
@ -1,77 +1,80 @@
|
||||||
{
|
{
|
||||||
extends: [
|
"extends": [
|
||||||
':semanticCommits',
|
":semanticCommits",
|
||||||
':semanticCommitTypeAll(deps)',
|
":semanticCommitTypeAll(deps)",
|
||||||
':semanticCommitScopeDisabled',
|
":semanticCommitScopeDisabled",
|
||||||
':dependencyDashboard',
|
|
||||||
':approveMajorUpdates',
|
":dependencyDashboard",
|
||||||
':automergeMinor',
|
":approveMajorUpdates",
|
||||||
':automergeLinters',
|
|
||||||
':automergeTesters',
|
":automergeMinor",
|
||||||
':automergeTypes',
|
":automergeLinters",
|
||||||
':maintainLockFilesWeekly',
|
":automergeTesters",
|
||||||
':enableVulnerabilityAlerts',
|
":automergeTypes",
|
||||||
'helpers:pinGitHubActionDigests',
|
|
||||||
|
":maintainLockFilesWeekly",
|
||||||
|
":enableVulnerabilityAlerts",
|
||||||
|
"helpers:pinGitHubActionDigests"
|
||||||
],
|
],
|
||||||
packageRules: [
|
"packageRules": [
|
||||||
{
|
{
|
||||||
groupName: 'linters',
|
"groupName": "linters",
|
||||||
matchUpdateTypes: [
|
"matchUpdateTypes": [
|
||||||
'minor',
|
"minor",
|
||||||
'patch',
|
"patch"
|
||||||
],
|
],
|
||||||
matchDepNames: [
|
"matchDepNames": [
|
||||||
'golangci/golangci-lint',
|
"golangci/golangci-lint"
|
||||||
],
|
],
|
||||||
automerge: true,
|
"automerge": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
groupName: 'testing',
|
"groupName": "testing",
|
||||||
matchUpdateTypes: [
|
"matchUpdateTypes": [
|
||||||
'minor',
|
"minor",
|
||||||
'patch',
|
"patch"
|
||||||
],
|
],
|
||||||
matchDepNames: [
|
"matchDepNames": [
|
||||||
'github.com/stretchr/testify',
|
"github.com/stretchr/testify"
|
||||||
],
|
],
|
||||||
automerge: true,
|
"automerge": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
groupName: 'github-actions',
|
"groupName": "github-actions",
|
||||||
matchUpdateTypes: [
|
"matchUpdateTypes": [
|
||||||
'minor',
|
"minor",
|
||||||
'patch',
|
"patch"
|
||||||
],
|
],
|
||||||
matchDepTypes: [
|
"matchDepTypes": [
|
||||||
'action',
|
"action"
|
||||||
],
|
],
|
||||||
automerge: true,
|
"automerge": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
groupName: 'gitlab-ci',
|
"groupName": "gitlab-ci",
|
||||||
matchUpdateTypes: [
|
"matchUpdateTypes": [
|
||||||
'minor',
|
"minor",
|
||||||
'patch',
|
"patch"
|
||||||
],
|
],
|
||||||
matchPackageNames: [
|
"matchPackageNames": [
|
||||||
'registry.gitlab.com/gitlab-org/release-cli',
|
"registry.gitlab.com/gitlab-org/release-cli"
|
||||||
],
|
],
|
||||||
automerge: true,
|
"automerge": true
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
customManagers: [
|
"customManagers": [
|
||||||
{
|
{
|
||||||
customType: 'regex',
|
"customType": "regex",
|
||||||
fileMatch: [
|
"fileMatch": [
|
||||||
'.+\\.ya?ml$',
|
".+\\.ya?ml$"
|
||||||
],
|
],
|
||||||
matchStrings: [
|
"matchStrings": [
|
||||||
': (?<currentValue>.+) # renovate: datasource=(?<datasource>[a-z-]+) depName=(?<depName>[^\\s]+)(?: lookupName=(?<packageName>[^\\s]+))?(?: versioning=(?<versioning>[a-z-]+))?(?: extractVersion=(?<extractVersion>[^\\s]+))?',
|
": (?<currentValue>.+) # renovate: datasource=(?<datasource>[a-z-]+) depName=(?<depName>[^\\s]+)(?: lookupName=(?<lookupName>[^\\s]+))?(?: versioning=(?<versioning>[a-z-]+))?(?: extractVersion=(?<extractVersion>[^\\s]+))?"
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
],
|
|
||||||
postUpdateOptions: [
|
|
||||||
'gomodUpdateImportPaths',
|
|
||||||
'gomodTidy',
|
|
||||||
],
|
],
|
||||||
|
"postUpdateOptions": [
|
||||||
|
"gomodUpdateImportPaths",
|
||||||
|
"gomodTidy"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
.github/workflows/ci.yaml
vendored
14
.github/workflows/ci.yaml
vendored
|
|
@ -10,10 +10,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
|
@ -27,10 +27,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ jobs:
|
||||||
run: go test -v -race -coverpkg=./... -coverprofile=coverage.txt ./...
|
run: go test -v -race -coverpkg=./... -coverprofile=coverage.txt ./...
|
||||||
|
|
||||||
- name: Upload results to Codecov
|
- name: Upload results to Codecov
|
||||||
uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5
|
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
|
|
@ -46,10 +46,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
|
|
||||||
2
.github/workflows/docs.yaml
vendored
2
.github/workflows/docs.yaml
vendored
|
|
@ -13,7 +13,7 @@ jobs:
|
||||||
id-token: write # To update the deployment status
|
id-token: write # To update the deployment status
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
with:
|
with:
|
||||||
lfs: "true"
|
lfs: "true"
|
||||||
|
|
||||||
|
|
|
||||||
2
.github/workflows/mirror.yaml
vendored
2
.github/workflows/mirror.yaml
vendored
|
|
@ -11,7 +11,7 @@ jobs:
|
||||||
REMOTE: mirror
|
REMOTE: mirror
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
with:
|
with:
|
||||||
# Need all to fetch all tags so we can push them
|
# Need all to fetch all tags so we can push them
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
|
||||||
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
|
|
@ -14,10 +14,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
|
|
||||||
4
.github/workflows/releaser-pleaser.yaml
vendored
4
.github/workflows/releaser-pleaser.yaml
vendored
|
|
@ -18,12 +18,12 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
|
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
|
|
||||||
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -1,17 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## [v0.5.0](https://github.com/apricote/releaser-pleaser/releases/tag/v0.5.0)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
- **gitlab**: make job dependencies configurable and run immediately (#101)
|
|
||||||
- **github**: mark pre-releases correctly (#110)
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
- use commits with slightly invalid messages in release notes (#105)
|
|
||||||
- create CHANGELOG.md if it does not exist (#108)
|
|
||||||
|
|
||||||
## [v0.4.2](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.2)
|
## [v0.4.2](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.2)
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ inputs:
|
||||||
outputs: {}
|
outputs: {}
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: docker://ghcr.io/apricote/releaser-pleaser:v0.5.0 # x-releaser-pleaser-version
|
image: docker://ghcr.io/apricote/releaser-pleaser:v0.4.2 # x-releaser-pleaser-version
|
||||||
args:
|
args:
|
||||||
- run
|
- run
|
||||||
- --forge=github
|
- --forge=github
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func run(cmd *cobra.Command, _ []string) error {
|
||||||
logger,
|
logger,
|
||||||
flagBranch,
|
flagBranch,
|
||||||
conventionalcommits.NewParser(logger),
|
conventionalcommits.NewParser(logger),
|
||||||
versioning.SemVer,
|
versioning.SemVerNextVersion,
|
||||||
extraFiles,
|
extraFiles,
|
||||||
[]updater.NewUpdater{updater.Generic},
|
[]updater.NewUpdater{updater.Generic},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,7 @@ It is being distributed through the CI/CD Catalog: [apricote/releaser-pleaser](h
|
||||||
|
|
||||||
The `apricote/releaser-pleaser` action is released together with `releaser-pleaser` and they share the version number.
|
The `apricote/releaser-pleaser` action is released together with `releaser-pleaser` and they share the version number.
|
||||||
|
|
||||||
The component does not support floating tags (e.g.
|
The component does not support floating tags (e.g. `v1`) right now ([#31](https://github.com/apricote/releaser-pleaser/issues/31)). You have to use the full version or commit SHA instead: `apricote/releaser-pleaser@v0.4.0`.
|
||||||
`v1`) right now ([#31](https://github.com/apricote/releaser-pleaser/issues/31)). You have to use the full version or commit SHA instead:
|
|
||||||
`apricote/releaser-pleaser@v0.4.0`.
|
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
|
|
@ -23,5 +21,3 @@ The following inputs are supported by the component.
|
||||||
| `branch` | This branch is used as the target for releases. | `main` | `master` |
|
| `branch` | This branch is used as the target for releases. | `main` | `master` |
|
||||||
| `token` (**required**) | GitLab access token for creating and updating release PRs | | `$RELEASER_PLEASER_TOKEN` |
|
| `token` (**required**) | GitLab access token for creating and updating release PRs | | `$RELEASER_PLEASER_TOKEN` |
|
||||||
| `extra-files` | List of files that are scanned for version references. | `""` | <pre><code>version/version.go<br>deploy/deployment.yaml</code></pre> |
|
| `extra-files` | List of files that are scanned for version references. | `""` | <pre><code>version/version.go<br>deploy/deployment.yaml</code></pre> |
|
||||||
| `stage` | Stage the job runs in. Must exists. | `build` | `test` |
|
|
||||||
| `needs` | Other jobs the releaser-pleaser job depends on. | `[]` | <pre><code>- validate-foo<br>- prepare-bar</code></pre> |
|
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -5,7 +5,7 @@ go 1.23.0
|
||||||
require (
|
require (
|
||||||
github.com/blang/semver/v4 v4.0.0
|
github.com/blang/semver/v4 v4.0.0
|
||||||
github.com/go-git/go-git/v5 v5.12.0
|
github.com/go-git/go-git/v5 v5.12.0
|
||||||
github.com/google/go-github/v66 v66.0.0
|
github.com/google/go-github/v65 v65.0.0
|
||||||
github.com/leodido/go-conventionalcommits v0.12.0
|
github.com/leodido/go-conventionalcommits v0.12.0
|
||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -47,8 +47,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-github/v66 v66.0.0 h1:ADJsaXj9UotwdgK8/iFZtv7MLc8E8WBl62WLd/D/9+M=
|
github.com/google/go-github/v65 v65.0.0 h1:pQ7BmO3DZivvFk92geC0jB0q2m3gyn8vnYPgV7GSLhQ=
|
||||||
github.com/google/go-github/v66 v66.0.0/go.mod h1:+4SO9Zkuyf8ytMj0csN1NR/5OTR+MfqPp8P8dVlcvY4=
|
github.com/google/go-github/v65 v65.0.0/go.mod h1:DvrqWo5hvsdhJvHd4WyVF9ttANN3BniqjP8uTFMNb60=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||||
|
|
|
||||||
|
|
@ -35,25 +35,15 @@ func (c *Parser) Analyze(commits []git.Commit) ([]commitparser.AnalyzedCommit, e
|
||||||
for _, commit := range commits {
|
for _, commit := range commits {
|
||||||
msg, err := c.machine.Parse([]byte(strings.TrimSpace(commit.Message)))
|
msg, err := c.machine.Parse([]byte(strings.TrimSpace(commit.Message)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if msg == nil {
|
|
||||||
c.logger.Warn("failed to parse message of commit, skipping", "commit.hash", commit.Hash, "err", err)
|
c.logger.Warn("failed to parse message of commit, skipping", "commit.hash", commit.Hash, "err", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Warn("failed to parse message of commit fully, trying to use as much as possible", "commit.hash", commit.Hash, "err", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
conventionalCommit, ok := msg.(*conventionalcommits.ConventionalCommit)
|
conventionalCommit, ok := msg.(*conventionalcommits.ConventionalCommit)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("unable to get ConventionalCommit from parser result: %T", msg)
|
return nil, fmt.Errorf("unable to get ConventionalCommit from parser result: %T", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if conventionalCommit.Type == "" {
|
|
||||||
// Parsing broke before getting the type, can not use the commit
|
|
||||||
c.logger.Warn("commit type was not parsed, skipping", "commit.hash", commit.Hash, "err", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
commitVersionBump := conventionalCommit.VersionBump(conventionalcommits.DefaultStrategy)
|
commitVersionBump := conventionalCommit.VersionBump(conventionalcommits.DefaultStrategy)
|
||||||
if commitVersionBump > conventionalcommits.UnknownVersion {
|
if commitVersionBump > conventionalcommits.UnknownVersion {
|
||||||
// We only care about releasable commits
|
// We only care about releasable commits
|
||||||
|
|
|
||||||
|
|
@ -125,24 +125,6 @@ func TestAnalyzeCommits(t *testing.T) {
|
||||||
},
|
},
|
||||||
wantErr: assert.NoError,
|
wantErr: assert.NoError,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
|
||||||
name: "success with body",
|
|
||||||
commits: []git.Commit{
|
|
||||||
{
|
|
||||||
Message: "feat: some thing (hz/fl!144)\n\nFixes #15\n\nDepends on !143",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
expectedCommits: []commitparser.AnalyzedCommit{
|
|
||||||
{
|
|
||||||
Commit: git.Commit{Message: "feat: some thing (hz/fl!144)\n\nFixes #15\n\nDepends on !143"},
|
|
||||||
Type: "feat",
|
|
||||||
Description: "some thing (hz/fl!144)",
|
|
||||||
BreakingChange: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
wantErr: assert.NoError,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/blang/semver/v4"
|
"github.com/blang/semver/v4"
|
||||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||||
"github.com/google/go-github/v66/github"
|
"github.com/google/go-github/v65/github"
|
||||||
|
|
||||||
"github.com/apricote/releaser-pleaser/internal/forge"
|
"github.com/apricote/releaser-pleaser/internal/forge"
|
||||||
"github.com/apricote/releaser-pleaser/internal/git"
|
"github.com/apricote/releaser-pleaser/internal/git"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
remoteName = "origin"
|
remoteName = "origin"
|
||||||
newFilePermissions = 0o644
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
|
|
@ -98,18 +97,13 @@ func (r *Repository) Checkout(_ context.Context, branch string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) UpdateFile(_ context.Context, path string, create bool, updaters []updater.Updater) error {
|
func (r *Repository) UpdateFile(_ context.Context, path string, updaters []updater.Updater) error {
|
||||||
worktree, err := r.r.Worktree()
|
worktree, err := r.r.Worktree()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fileFlags := os.O_RDWR
|
file, err := worktree.Filesystem.OpenFile(path, os.O_RDWR, 0)
|
||||||
if create {
|
|
||||||
fileFlags |= os.O_CREATE
|
|
||||||
}
|
|
||||||
|
|
||||||
file, err := worktree.Filesystem.OpenFile(path, fileFlags, newFilePermissions)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,9 @@ import (
|
||||||
"github.com/apricote/releaser-pleaser/internal/git"
|
"github.com/apricote/releaser-pleaser/internal/git"
|
||||||
)
|
)
|
||||||
|
|
||||||
var SemVer Strategy = semVer{}
|
var _ Strategy = SemVerNextVersion
|
||||||
|
|
||||||
type semVer struct{}
|
func SemVerNextVersion(r git.Releases, versionBump VersionBump, nextVersionType NextVersionType) (string, error) {
|
||||||
|
|
||||||
func (s semVer) NextVersion(r git.Releases, versionBump VersionBump, nextVersionType NextVersionType) (string, error) {
|
|
||||||
latest, err := parseSemverWithDefault(r.Latest)
|
latest, err := parseSemverWithDefault(r.Latest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to parse latest version: %w", err)
|
return "", fmt.Errorf("failed to parse latest version: %w", err)
|
||||||
|
|
@ -110,16 +108,3 @@ func parseSemverWithDefault(tag *git.Tag) (semver.Version, error) {
|
||||||
|
|
||||||
return parsedVersion, nil
|
return parsedVersion, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s semVer) IsPrerelease(version string) bool {
|
|
||||||
semVersion, err := parseSemverWithDefault(&git.Tag{Hash: "", Name: version})
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(semVersion.Pre) > 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"github.com/apricote/releaser-pleaser/internal/git"
|
"github.com/apricote/releaser-pleaser/internal/git"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSemVer_NextVersion(t *testing.T) {
|
func TestReleases_NextVersion(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
releases git.Releases
|
releases git.Releases
|
||||||
versionBump VersionBump
|
versionBump VersionBump
|
||||||
|
|
@ -326,7 +326,7 @@ func TestSemVer_NextVersion(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got, err := SemVer.NextVersion(tt.args.releases, tt.args.versionBump, tt.args.nextVersionType)
|
got, err := SemVerNextVersion(tt.args.releases, tt.args.versionBump, tt.args.nextVersionType)
|
||||||
if !tt.wantErr(t, err, fmt.Sprintf("SemVerNextVersion(Releases(%v, %v), %v, %v)", tt.args.releases.Latest, tt.args.releases.Stable, tt.args.versionBump, tt.args.nextVersionType)) {
|
if !tt.wantErr(t, err, fmt.Sprintf("SemVerNextVersion(Releases(%v, %v), %v, %v)", tt.args.releases.Latest, tt.args.releases.Stable, tt.args.versionBump, tt.args.nextVersionType)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -388,37 +388,3 @@ func TestVersionBumpFromCommits(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSemVer_IsPrerelease(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
version string
|
|
||||||
want bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "empty string",
|
|
||||||
version: "",
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "stable version",
|
|
||||||
version: "v1.0.0",
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "pre-release version",
|
|
||||||
version: "v1.0.0-rc.1+foo",
|
|
||||||
want: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "invalid version",
|
|
||||||
version: "ajfkdafjdsfj",
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
assert.Equalf(t, tt.want, SemVer.IsPrerelease(tt.version), "IsSemverPrerelease(%v)", tt.version)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,7 @@ import (
|
||||||
"github.com/apricote/releaser-pleaser/internal/git"
|
"github.com/apricote/releaser-pleaser/internal/git"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Strategy interface {
|
type Strategy = func(git.Releases, VersionBump, NextVersionType) (string, error)
|
||||||
NextVersion(git.Releases, VersionBump, NextVersionType) (string, error)
|
|
||||||
IsPrerelease(version string) bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type VersionBump conventionalcommits.VersionBump
|
type VersionBump conventionalcommits.VersionBump
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type ReleaserPleaser struct {
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
targetBranch string
|
targetBranch string
|
||||||
commitParser commitparser.CommitParser
|
commitParser commitparser.CommitParser
|
||||||
versioning versioning.Strategy
|
nextVersion versioning.Strategy
|
||||||
extraFiles []string
|
extraFiles []string
|
||||||
updaters []updater.NewUpdater
|
updaters []updater.NewUpdater
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +34,7 @@ func New(forge forge.Forge, logger *slog.Logger, targetBranch string, commitPars
|
||||||
logger: logger,
|
logger: logger,
|
||||||
targetBranch: targetBranch,
|
targetBranch: targetBranch,
|
||||||
commitParser: commitParser,
|
commitParser: commitParser,
|
||||||
versioning: versioningStrategy,
|
nextVersion: versioningStrategy,
|
||||||
extraFiles: extraFiles,
|
extraFiles: extraFiles,
|
||||||
updaters: updaters,
|
updaters: updaters,
|
||||||
}
|
}
|
||||||
|
|
@ -117,15 +117,15 @@ func (rp *ReleaserPleaser) createPendingRelease(ctx context.Context, pr *release
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
changelogText, err := pr.ChangelogText()
|
changelog, err := pr.ChangelogText()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if version should be marked latest
|
// TODO: pre-release & latest
|
||||||
|
|
||||||
logger.DebugContext(ctx, "Creating release on forge")
|
logger.DebugContext(ctx, "Creating release on forge")
|
||||||
err = rp.forge.CreateRelease(ctx, *pr.ReleaseCommit, version, changelogText, rp.versioning.IsPrerelease(version), true)
|
err = rp.forge.CreateRelease(ctx, *pr.ReleaseCommit, version, changelog, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create release on forge: %w", err)
|
return fmt.Errorf("failed to create release on forge: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -163,6 +163,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
releases, err := rp.forge.LatestTags(ctx)
|
releases, err := rp.forge.LatestTags(ctx)
|
||||||
|
|
@ -222,7 +223,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
|
||||||
|
|
||||||
versionBump := versioning.BumpFromCommits(analyzedCommits)
|
versionBump := versioning.BumpFromCommits(analyzedCommits)
|
||||||
// TODO: Set version in release pr
|
// TODO: Set version in release pr
|
||||||
nextVersion, err := rp.versioning.NextVersion(releases, versionBump, releaseOverrides.NextVersionType)
|
nextVersion, err := rp.nextVersion(releases, versionBump, releaseOverrides.NextVersionType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -252,14 +253,14 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
|
||||||
// Info for updaters
|
// Info for updaters
|
||||||
info := updater.ReleaseInfo{Version: nextVersion, ChangelogEntry: changelogEntry}
|
info := updater.ReleaseInfo{Version: nextVersion, ChangelogEntry: changelogEntry}
|
||||||
|
|
||||||
err = repo.UpdateFile(ctx, updater.ChangelogFile, true, updater.WithInfo(info, updater.Changelog))
|
err = repo.UpdateFile(ctx, updater.ChangelogFile, updater.WithInfo(info, updater.Changelog))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to update changelog file: %w", err)
|
return fmt.Errorf("failed to update changelog file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range rp.extraFiles {
|
for _, path := range rp.extraFiles {
|
||||||
// TODO: Check for missing files
|
// TODO: Check for missing files
|
||||||
err = repo.UpdateFile(ctx, path, false, updater.WithInfo(info, rp.updaters...))
|
err = repo.UpdateFile(ctx, path, updater.WithInfo(info, rp.updaters...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to run file updater: %w", err)
|
return fmt.Errorf("failed to run file updater: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,23 +15,17 @@ spec:
|
||||||
stage:
|
stage:
|
||||||
default: build
|
default: build
|
||||||
description: 'Defines the build stage'
|
description: 'Defines the build stage'
|
||||||
|
|
||||||
needs:
|
|
||||||
default: [ ]
|
|
||||||
type: array
|
|
||||||
description: 'Dependencies of the created Job'
|
|
||||||
# Remember to update docs/reference/gitlab-ci-component.md
|
# Remember to update docs/reference/gitlab-ci-component.md
|
||||||
---
|
---
|
||||||
|
|
||||||
releaser-pleaser:
|
releaser-pleaser:
|
||||||
stage: $[[ inputs.stage ]]
|
stage: $[[ inputs.stage ]]
|
||||||
needs: $[[ inputs.needs ]]
|
|
||||||
rules:
|
rules:
|
||||||
# There is no way to run a pipeline when the MR description is updated :(
|
# There is no way to run a pipeline when the MR description is updated :(
|
||||||
- if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]"
|
- if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]"
|
||||||
image:
|
image:
|
||||||
name: ghcr.io/apricote/releaser-pleaser:v0.5.0 # x-releaser-pleaser-version
|
name: ghcr.io/apricote/releaser-pleaser:v0.4.2 # x-releaser-pleaser-version
|
||||||
entrypoint: [ "" ]
|
entrypoint: [""]
|
||||||
variables:
|
variables:
|
||||||
GITLAB_TOKEN: $[[ inputs.token ]]
|
GITLAB_TOKEN: $[[ inputs.token ]]
|
||||||
script:
|
script:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue