Skip to content

Commit 2716376

Browse files
authored
Merge pull request #1011 from axodotdev/revert-remote-release
fix: use non-reserved SECRET name for github-releases-repo
2 parents 1ccde48 + 9d49d77 commit 2716376

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

book/src/reference/config.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,19 @@ Allows specifying which runner to use for a target. The keys within this table a
387387

388388
> since 0.14.0
389389
390-
Example: `github-releases-repo = "mycoolowner/myrepo"`
390+
Example: `github-releases-repo = "myorg/public"`
391391

392-
Allows specifying a different repo to publish GitHub Releases to than the current one. This can be used to publish to a public repo from a private one.
392+
Allows specifying a different repo to publish GitHub Releases to than the current one. This can be used to publish to a public repo from a private one. Let's assume you want to publish to `myorg/public` from `myorg/private`. Then in your config in `myorg/private`, you'd set `github-releases-repo = "myorg/public"`.
393393

394-
You need to also need to create a [GitHub Personal Access Token with the "repo" scope](https://github.com/settings/tokens/new?scopes=repo) that can access the target repo, and need to add it as a GitHub SECRET called `GITHUB_RELEASES_TOKEN` **in the repo the workflow will run on**.
394+
To ensure the workflow has permission to do this, you need to create a [GitHub Personal Access Token with the "repo" scope](https://github.com/settings/tokens/new?scopes=repo) that can access `myorg/public`. This must be added as a GitHub SECRET called `GH_RELEASES_TOKEN` on `myorg/private`.
395395

396-
i.e. if you're running the publish workflow in `myorg/private` and want to publish to `myorg/public`, the token needs *access* to `myorg/public`, but should be added as a SECRET to `myorg/private`.
396+
GitHub Releases isn't really designed for this, so there's a few strange things that will happen here:
397+
398+
* GitHub Releases always requires a commit to be tagged, and in this case the tag would be on `myorg/public` even though the workflow is running on `myorg/private`, which (presumably) has unrelated commits. Currently **we will tag the latest commit on the [default branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches#about-the-default-branch) of `myorg/public`**. If you're using [the dispatch-releases flow](#dispatch-releases), no tag will be created on `myorg/private`.
399+
400+
* GitHub Releases will provide a source tarball pointing at the tagged commit on `myorg/public`, but that's (presumably) not the source that your release was actually built from. This cannot be disabled, but it's also essentially harmless. However **cargo-dist uploads its own source tarball and that *WILL* contain the source of the private repo**. If you don't want this, use [the `source-tarball = false` setting](#source-tarball).
401+
402+
In the future we'll introduce some mechanism for identifying a git submodule where the commit on `myorg/public` should be sourced from, as we expect that to be a common usecase for these kinds of remote releases.
397403

398404

399405
### global-artifacts-jobs

cargo-dist/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub struct DistMetadata {
327327

328328
/// Publish GitHub Releases to this repo instead of the current one
329329
///
330-
/// The user must also set GITHUB_RELEASES_TOKEN in their SECRETS
330+
/// The user must also set GH_RELEASES_TOKEN in their SECRETS
331331
#[serde(skip_serializing_if = "Option::is_none")]
332332
pub github_releases_repo: Option<GithubRepoPair>,
333333

cargo-dist/templates/ci/github/release.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ jobs:
576576
{{%- if github_releases_repo %}}
577577
owner: {{{ github_releases_repo.owner }}}
578578
repo: {{{ github_releases_repo.repo }}}
579-
token: ${{ secrets.GITHUB_RELEASES_TOKEN }}
579+
token: ${{ secrets.GH_RELEASES_TOKEN }}
580580
{{%- endif %}}
581581
tag: ${{ needs.plan.outputs.tag }}
582582
{{%- if create_release %}}

cargo-dist/tests/snapshots/axolotlsay_no_locals.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: cargo-dist/tests/gallery/dist.rs
2+
source: cargo-dist/tests/gallery/dist/snapshot.rs
33
expression: self.payload
44
---
55
================ dist-manifest.json ================
@@ -463,7 +463,7 @@ jobs:
463463
with:
464464
owner: "custom-owner"
465465
repo: "cool-repo"
466-
token: ${{ secrets.GITHUB_RELEASES_TOKEN }}
466+
token: ${{ secrets.GH_RELEASES_TOKEN }}
467467
tag: ${{ needs.plan.outputs.tag }}
468468
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
469469
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}

0 commit comments

Comments
 (0)