Skip to content

Commit c007a95

Browse files
authored
Merge branch 'master' into ci-job-token
2 parents cd1e41a + d780e82 commit c007a95

File tree

8 files changed

+860
-1593
lines changed

8 files changed

+860
-1593
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
name: release
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
21+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2323
with:
2424
cache: npm
2525
node-version: lts/*

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
- windows-latest
2424
runs-on: "${{ matrix.os }}"
2525
steps:
26-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2727
- name: "Use Node.js ${{ matrix.node-version }}"
28-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
28+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2929
with:
3030
node-version: "${{ matrix.node-version }}"
3131
cache: npm
@@ -37,9 +37,9 @@ jobs:
3737
runs-on: ubuntu-latest
3838
needs: test_matrix
3939
steps:
40-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
40+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4141
- name: "Use Node.js ${{ matrix.node-version }}"
42-
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
42+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
4343
with:
4444
node-version: "${{ matrix.node-version }}"
4545
cache: npm

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Agent Guidelines for @semantic-release/gitlab
2+
3+
## Commands
4+
5+
- **Test**: `npm test` or `npm run test`
6+
- **Lint**: `npm run lint`
7+
- **Fix linting**: `npm run lint:fix`
8+
- **Coverage**: Tests include coverage reporting via c8
9+
10+
## Code Style
11+
12+
- **Node.js Version**: 20.8.1+
13+
- **Module type**: ES modules (`"type": "module"`)
14+
- **Formatting**: Prettier with 120 character line width and ES5 trailing commas
15+
- **Testing**: AVA test framework
16+
- **Coverage**: c8 for code coverage
17+
18+
## Development Guidelines
19+
20+
- **Perform minimal changes**: Focus on the specific issue and make the smallest possible changes
21+
- **Focus on reviewers**: Write clear, understandable code that is easy to review
22+
- **Use semantic commits**: Follow conventional commit format (e.g., `feat:`, `fix:`, `docs:`, `test:`)
23+
- **Run tests and formatting before committing**: Always run `npm test` and `npm run lint` before making commits
24+
25+
## Project Structure
26+
27+
- `lib/` - Core library modules
28+
- `test/` - Test files (using AVA)
29+
- `index.js` - Main entry point
30+
- Configuration files support semantic-release conventions
31+
32+
## Testing Requirements
33+
34+
- All changes must maintain or improve test coverage
35+
- Tests use nock for HTTP mocking
36+
- Integration tests verify GitLab API interactions
37+
- Run `npm test` to execute the full test suite
38+
39+
## Semantic Release Integration
40+
41+
This is a semantic-release plugin, so changes should follow semantic versioning principles and conventional commit formats for automated releases.

README.md

Lines changed: 62 additions & 61 deletions
Large diffs are not rendered by default.

lib/publish.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default async (pluginConfig, context) => {
2828
const { projectPath, projectApiUrl } = getProjectContext(context, gitlabUrl, gitlabApiUrl, repositoryUrl);
2929

3030
const encodedGitTag = encodeURIComponent(gitTag);
31-
const encodedVersion = encodeURIComponent(version);
3231
const apiOptions = {
3332
headers: {
3433
[tokenHeader]: gitlabToken,
@@ -76,6 +75,7 @@ export default async (pluginConfig, context) => {
7675
const filepath = asset.filepath ? template(asset.filepath)(context) : undefined;
7776
const target = asset.target ? template(asset.target)(context) : undefined;
7877
const status = asset.status ? template(asset.status)(context) : undefined;
78+
const packageName = asset.packageName ? template(asset.packageName)(context) : "release";
7979

8080
if (_url) {
8181
assetsList.push({ label, rawUrl: _url, type, filepath });
@@ -103,17 +103,21 @@ export default async (pluginConfig, context) => {
103103
debug("file filepath: %o", filepath);
104104
debug("file target: %o", target);
105105
debug("file status: %o", status);
106+
debug("package name: %o", packageName);
106107

107108
let uploadEndpoint;
108109
let response;
109110

110111
if (target === "generic_package") {
112+
const finalLabel = label ?? pathlib.basename(file);
111113
// Upload generic packages
112-
const encodedLabel = encodeURIComponent(label);
114+
const encodedVersion = encodeURIComponent(version);
115+
const encodedPackageName = encodeURIComponent(packageName);
116+
const encodedLabel = encodeURIComponent(finalLabel);
113117
// https://docs.gitlab.com/ee/user/packages/generic_packages/#publish-a-package-file
114118
uploadEndpoint = urlJoin(
115119
projectApiUrl,
116-
`packages/generic/release/${encodedVersion}/${encodedLabel}?${
120+
`packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}?${
117121
status ? `status=${status}&` : ""
118122
}select=package_file`
119123
);
@@ -128,9 +132,12 @@ export default async (pluginConfig, context) => {
128132
}
129133

130134
// https://docs.gitlab.com/ee/user/packages/generic_packages/#download-package-file
131-
const url = urlJoin(projectApiUrl, `packages/generic/release/${encodedVersion}/${encodedLabel}`);
135+
const url = urlJoin(
136+
projectApiUrl,
137+
`packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}`
138+
);
132139

133-
assetsList.push({ label, alt: "release", url, type: "package", filepath });
140+
assetsList.push({ label: finalLabel, alt: packageName, url, type: "package", filepath });
134141

135142
logger.log("Uploaded file: %s (%s)", url, response.file.url);
136143
} else {

0 commit comments

Comments
 (0)