Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds SKIP_NPM_PUBLISH and SKIP_DOCKER_PUBLISH #22

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,72 @@ Now all you need to do is create a release:
npx semantic-release
```

## πŸ—οΈ GitHub general usage

If you do not plan to publish to `npm` _or_ `ghcr` but still want to cut tags
and GitHub releases with this system, you can specify `SKIP_NPM_PUBLISH` and
`SKIP_DOCKER_PUBLISH`. This will still publish releases, generate semver tags,
and generate GitHub release notes. But it will skip attempting to publish

Then, in a separate GitHub action, you can watch for the releases and upload assets
manually. For example, when building a Go application:

```yaml
name: Semantic release
on:
push:
branches:
- main
- beta
workflow_dispatch:
jobs:
release:
name: Semantic release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: "☁️ checkout repository"
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "πŸš€ release"
id: semantic-release
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
SKIP_NPM_PUBLISH: true
SKIP_DOCKER_PUBLISH: true
uses: open-sauced/release@v2
outputs:
release-tag: ${{ steps.semantic-release.outputs.release-tag }}
build:
needs:
- release
runs-on: ubuntu-latest
permissions:
contents: write # release changes require contents write
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Check out code
uses: actions/checkout@v3
- name: Build and upload Go binaries
env:
GH_TOKEN: ${{ github.token }}
run: |
go build -o build/my-go-binary
gh release upload ${{ needs.release.outputs.release-tag }} build/my-go-binary
```

## πŸ”§ Configuration

See each [plugin](#-plugins) documentation for required installation and configuration steps.
Expand Down
50 changes: 27 additions & 23 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ addPlugin("@semantic-release/changelog", {
> All notable changes to this project will be documented in this file`
});

const pkgRoot = NPM_PACKAGE_ROOT || ".";
addPlugin("@semantic-release/npm", {
tarballDir: "pack",
pkgRoot,
});
if (process.env.SKIP_NPM_PUBLISH === undefined) {
const pkgRoot = NPM_PACKAGE_ROOT || ".";
addPlugin("@semantic-release/npm", {
tarballDir: "pack",
pkgRoot,
});
}

const actionExists = existsSync("./action.yml");
if (actionExists) {
Expand Down Expand Up @@ -164,23 +166,25 @@ if (manifestExists && GITHUB_REF === "refs/heads/main") {
});
}

const packageFilesPrefix = process.env.NPM_PACKAGE_ROOT ? `${process.env.NPM_PACKAGE_ROOT}/` : "";
addPlugin("@semantic-release/git", {
"assets": [
"LICENSE*",
"CHANGELOG.md",
`${packageFilesPrefix}package.json`,
`${packageFilesPrefix}package-lock.json`,
`${packageFilesPrefix}npm-shrinkwrap.json`,
`${packageFilesPrefix}yarn.lock`,
`${packageFilesPrefix}pnpm-lock.yaml`,
"public/**/*",
"supabase/**/*",
"action.yml",
"manifest.json"
],
"message": `chore(<%= nextRelease.type %>): release <%= nextRelease.version %> <%= nextRelease.channel !== null ? \`on \${nextRelease.channel} channel \` : '' %>[skip ci]\n\n<%= nextRelease.notes %>`
});
if (process.env.SKIP_NPM_PUBLISH === undefined) {
const packageFilesPrefix = process.env.NPM_PACKAGE_ROOT ? `${process.env.NPM_PACKAGE_ROOT}/` : "";
addPlugin("@semantic-release/git", {
"assets": [
"LICENSE*",
"CHANGELOG.md",
`${packageFilesPrefix}package.json`,
`${packageFilesPrefix}package-lock.json`,
`${packageFilesPrefix}npm-shrinkwrap.json`,
`${packageFilesPrefix}yarn.lock`,
`${packageFilesPrefix}pnpm-lock.yaml`,
"public/**/*",
"supabase/**/*",
"action.yml",
"manifest.json"
],
"message": `chore(<%= nextRelease.type %>): release <%= nextRelease.version %> <%= nextRelease.channel !== null ? \`on \${nextRelease.channel} channel \` : '' %>[skip ci]\n\n<%= nextRelease.notes %>`
});
}

addPlugin("@semantic-release/github", {
"addReleases": "bottom",
Expand All @@ -193,7 +197,7 @@ addPlugin("@semantic-release/github", {
});

const dockerExists = existsSync("./Dockerfile");
if (dockerExists) {
if (dockerExists && process.env.SKIP_DOCKER_PUBLISH === undefined) {
addPlugin("eclass-docker-fork", {
"baseImageName": `${owner}/${repo}`,
"registries": [
Expand Down
Loading