Skip to content

Commit f124a4a

Browse files
committed
Merge remote-tracking branch 'origin/master' into copilot/fix-1b0ecfd2-e1c4-42cf-abe8-045e0974e3a9
2 parents 0df7835 + 9037794 commit f124a4a

File tree

8 files changed

+283
-91
lines changed

8 files changed

+283
-91
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- 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
@@ -39,7 +39,7 @@ jobs:
3939
steps:
4040
- 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: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ If you need to bypass the proxy for some hosts, configure the `NO_PROXY` environ
102102
Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array` of
103103
[globs](https://github.com/isaacs/node-glob#glob-primer) and `Object`s with the following properties:
104104

105-
| Property | Description | Default |
106-
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
107-
| `path` | **Required**, unless `url` is set. A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. Supports [Lodash templating](https://lodash.com/docs#template). | - |
108-
| `url` | Alternative to setting `path` this provides the ability to add links to releases, e.g. URLs to container images. Supports [Lodash templating](https://lodash.com/docs#template). | - |
109-
| `label` | Short description of the file displayed on the GitLab release. Ignored if `path` matches more than one file. Supports [Lodash templating](https://lodash.com/docs#template). | File name extracted from the `path`. |
110-
| `type` | Asset type displayed on the GitLab release. Can be `runbook`, `package`, `image` and `other` (see official documents on [link types](https://docs.gitlab.com/user/project/releases/release_fields/#link-types)). Supports [Lodash templating](https://lodash.com/docs#template). | `other` |
111-
| `filepath` | A filepath for creating a permalink pointing to the asset (requires GitLab 12.9+, see official documents on [permanent links](https://docs.gitlab.com/user/project/releases/release_fields/#permanent-links-to-release-assets)). Ignored if `path` matches more than one file. Supports [Lodash templating](https://lodash.com/docs#template). | - |
112-
| `target` | Controls where the file is uploaded to. Can be set to `project_upload` for storing the file as [project upload](https://docs.gitlab.com/api/project_markdown_uploads/#upload-a-file) or `generic_package` for storing the file as [generic package](https://docs.gitlab.com/user/packages/generic_packages/). | `project_upload` |
113-
| `status` | This is only applied, if `target` is set to `generic_package`. The generic package status. Can be `default` and `hidden` (see official documents on [generic packages](https://docs.gitlab.com/user/packages/generic_packages/)). | `default` |
105+
| Property | Description | Default |
106+
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
107+
| `path` | **Required**, unless `url` is set. A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. Supports [Lodash templating](https://lodash.com/docs#template). | - |
108+
| `url` | Alternative to setting `path` this provides the ability to add links to releases, e.g. URLs to container images. Supports [Lodash templating](https://lodash.com/docs#template). | - |
109+
| `label` | Short description of the file displayed on the GitLab release. Ignored if `path` matches more than one file. Supports [Lodash templating](https://lodash.com/docs#template). | File name extracted from the `path`. |
110+
| `type` | Asset type displayed on the GitLab release. Can be `runbook`, `package`, `image` and `other` (see official documents on [link types](https://docs.gitlab.com/user/project/releases/release_fields/#link-types)). Supports [Lodash templating](https://lodash.com/docs#template). | `other` |
111+
| `filepath` | A filepath for creating a permalink pointing to the asset (requires GitLab 12.9+, see official documents on [permanent links](https://docs.gitlab.com/user/project/releases/release_fields/#permanent-links-to-release-assets)). Ignored if `path` matches more than one file. Supports [Lodash templating](https://lodash.com/docs#template). | - |
112+
| `target` | Controls where the file is uploaded to. Can be set to `project_upload` for storing the file as [project upload](https://docs.gitlab.com/api/project_markdown_uploads/#upload-a-file) or `generic_package` for storing the file as [generic package](https://docs.gitlab.com/user/packages/generic_packages/). | `project_upload` |
113+
| `packageName` | This is only applied if `target` is set to `generic_package`. It defines the package name (`:package_name`) to upload asset file to. More information could be found at [Publish a package](https://docs.gitlab.com/user/packages/generic_packages/#publish-a-package) | `release` |
114+
| `status` | This is only applied, if `target` is set to `generic_package`. The generic package status. Can be `default` and `hidden` (see official documents on [generic packages](https://docs.gitlab.com/user/packages/generic_packages/)). | `default` |
114115

115116
Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
116117
can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together

lib/publish.js

Lines changed: 6 additions & 2 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
"PRIVATE-TOKEN": gitlabToken,
@@ -128,6 +127,8 @@ export default async (pluginConfig, context) => {
128127
if (asset.target === "generic_package") {
129128
const finalLabel = asset.label ?? pathlib.basename(file);
130129
// Upload generic packages
130+
const encodedVersion = encodeURIComponent(version);
131+
const encodedPackageName = encodeURIComponent(packageName);
131132
const encodedLabel = encodeURIComponent(finalLabel);
132133
// https://docs.gitlab.com/ee/user/packages/generic_packages/#publish-a-package-file
133134
uploadEndpoint = urlJoin(
@@ -147,7 +148,10 @@ export default async (pluginConfig, context) => {
147148
}
148149

149150
// https://docs.gitlab.com/ee/user/packages/generic_packages/#download-package-file
150-
const url = urlJoin(projectApiUrl, `packages/generic/release/${encodedVersion}/${encodedLabel}`);
151+
const url = urlJoin(
152+
projectApiUrl,
153+
`packages/generic/${encodedPackageName}/${encodedVersion}/${encodedLabel}`
154+
);
151155

152156
assetsList.push({ label: finalLabel, alt: "release", url, type: "package", filepath: asset.filepath });
153157

0 commit comments

Comments
 (0)