Skip to content

Commit

Permalink
Merge pull request #22 from jpmcb/main
Browse files Browse the repository at this point in the history
feat: Adds `SKIP_NPM_PUBLISH` and `SKIP_DOCKER_PUBLISH`
  • Loading branch information
jpmcb authored Sep 1, 2023
2 parents 70c6d08 + c89740d commit 76c74b4
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 23 deletions.
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

0 comments on commit 76c74b4

Please sign in to comment.