Skip to content

Commit 76c74b4

Browse files
authored
Merge pull request #22 from jpmcb/main
feat: Adds `SKIP_NPM_PUBLISH` and `SKIP_DOCKER_PUBLISH`
2 parents 70c6d08 + c89740d commit 76c74b4

File tree

2 files changed

+93
-23
lines changed

2 files changed

+93
-23
lines changed

README.md

+66
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,72 @@ Now all you need to do is create a release:
160160
npx semantic-release
161161
```
162162

163+
## 🏗️ GitHub general usage
164+
165+
If you do not plan to publish to `npm` _or_ `ghcr` but still want to cut tags
166+
and GitHub releases with this system, you can specify `SKIP_NPM_PUBLISH` and
167+
`SKIP_DOCKER_PUBLISH`. This will still publish releases, generate semver tags,
168+
and generate GitHub release notes. But it will skip attempting to publish
169+
170+
Then, in a separate GitHub action, you can watch for the releases and upload assets
171+
manually. For example, when building a Go application:
172+
173+
```yaml
174+
name: Semantic release
175+
176+
on:
177+
push:
178+
branches:
179+
- main
180+
- beta
181+
workflow_dispatch:
182+
183+
jobs:
184+
release:
185+
name: Semantic release
186+
runs-on: ubuntu-latest
187+
timeout-minutes: 10
188+
steps:
189+
- name: "☁️ checkout repository"
190+
uses: actions/checkout@v3
191+
with:
192+
fetch-depth: 0
193+
194+
- name: "🚀 release"
195+
id: semantic-release
196+
env:
197+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
198+
SKIP_NPM_PUBLISH: true
199+
SKIP_DOCKER_PUBLISH: true
200+
uses: open-sauced/release@v2
201+
202+
outputs:
203+
release-tag: ${{ steps.semantic-release.outputs.release-tag }}
204+
205+
build:
206+
needs:
207+
- release
208+
runs-on: ubuntu-latest
209+
permissions:
210+
contents: write # release changes require contents write
211+
212+
steps:
213+
- name: Set up Go
214+
uses: actions/setup-go@v4
215+
with:
216+
go-version: 1.21
217+
218+
- name: Check out code
219+
uses: actions/checkout@v3
220+
221+
- name: Build and upload Go binaries
222+
env:
223+
GH_TOKEN: ${{ github.token }}
224+
run: |
225+
go build -o build/my-go-binary
226+
gh release upload ${{ needs.release.outputs.release-tag }} build/my-go-binary
227+
```
228+
163229
## 🔧 Configuration
164230

165231
See each [plugin](#-plugins) documentation for required installation and configuration steps.

release.config.js

+27-23
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ addPlugin("@semantic-release/changelog", {
118118
> All notable changes to this project will be documented in this file`
119119
});
120120

121-
const pkgRoot = NPM_PACKAGE_ROOT || ".";
122-
addPlugin("@semantic-release/npm", {
123-
tarballDir: "pack",
124-
pkgRoot,
125-
});
121+
if (process.env.SKIP_NPM_PUBLISH === undefined) {
122+
const pkgRoot = NPM_PACKAGE_ROOT || ".";
123+
addPlugin("@semantic-release/npm", {
124+
tarballDir: "pack",
125+
pkgRoot,
126+
});
127+
}
126128

127129
const actionExists = existsSync("./action.yml");
128130
if (actionExists) {
@@ -164,23 +166,25 @@ if (manifestExists && GITHUB_REF === "refs/heads/main") {
164166
});
165167
}
166168

167-
const packageFilesPrefix = process.env.NPM_PACKAGE_ROOT ? `${process.env.NPM_PACKAGE_ROOT}/` : "";
168-
addPlugin("@semantic-release/git", {
169-
"assets": [
170-
"LICENSE*",
171-
"CHANGELOG.md",
172-
`${packageFilesPrefix}package.json`,
173-
`${packageFilesPrefix}package-lock.json`,
174-
`${packageFilesPrefix}npm-shrinkwrap.json`,
175-
`${packageFilesPrefix}yarn.lock`,
176-
`${packageFilesPrefix}pnpm-lock.yaml`,
177-
"public/**/*",
178-
"supabase/**/*",
179-
"action.yml",
180-
"manifest.json"
181-
],
182-
"message": `chore(<%= nextRelease.type %>): release <%= nextRelease.version %> <%= nextRelease.channel !== null ? \`on \${nextRelease.channel} channel \` : '' %>[skip ci]\n\n<%= nextRelease.notes %>`
183-
});
169+
if (process.env.SKIP_NPM_PUBLISH === undefined) {
170+
const packageFilesPrefix = process.env.NPM_PACKAGE_ROOT ? `${process.env.NPM_PACKAGE_ROOT}/` : "";
171+
addPlugin("@semantic-release/git", {
172+
"assets": [
173+
"LICENSE*",
174+
"CHANGELOG.md",
175+
`${packageFilesPrefix}package.json`,
176+
`${packageFilesPrefix}package-lock.json`,
177+
`${packageFilesPrefix}npm-shrinkwrap.json`,
178+
`${packageFilesPrefix}yarn.lock`,
179+
`${packageFilesPrefix}pnpm-lock.yaml`,
180+
"public/**/*",
181+
"supabase/**/*",
182+
"action.yml",
183+
"manifest.json"
184+
],
185+
"message": `chore(<%= nextRelease.type %>): release <%= nextRelease.version %> <%= nextRelease.channel !== null ? \`on \${nextRelease.channel} channel \` : '' %>[skip ci]\n\n<%= nextRelease.notes %>`
186+
});
187+
}
184188

185189
addPlugin("@semantic-release/github", {
186190
"addReleases": "bottom",
@@ -193,7 +197,7 @@ addPlugin("@semantic-release/github", {
193197
});
194198

195199
const dockerExists = existsSync("./Dockerfile");
196-
if (dockerExists) {
200+
if (dockerExists && process.env.SKIP_DOCKER_PUBLISH === undefined) {
197201
addPlugin("eclass-docker-fork", {
198202
"baseImageName": `${owner}/${repo}`,
199203
"registries": [

0 commit comments

Comments
 (0)