Skip to content

Commit b924d71

Browse files
committed
Revert "Merge pull request #29 from uclahs-cds/nwiltsie-attach-tarball"
This reverts commit e539242, reversing changes made to a452e40.
1 parent cd638f1 commit b924d71

13 files changed

+24
-162
lines changed

.github/workflows/internal-alias.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ permissions:
1616
jobs:
1717
update-alias:
1818
uses: ./.github/workflows/wf-alias-release.yaml
19+
# Secrets are only required until tool-create-release is made public
20+
secrets: inherit

.github/workflows/internal-finalize.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
finalize-release:
2020
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'automation-create-release') }}
2121
uses: ./.github/workflows/wf-finalize-release.yaml
22+
secrets: inherit
2223
with:
2324
draft: false
24-
secrets:
25-
token: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}

.github/workflows/internal-prepare.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ jobs:
2929
with:
3030
bump_type: ${{ inputs.bump_type }}
3131
prerelease: ${{ inputs.prerelease }}
32-
secrets:
33-
token: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}
32+
# Secrets are only required until tool-create-release is made public
33+
secrets: inherit
Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
---
22
on:
33
workflow_call:
4-
inputs:
5-
# These inputs are taken directly from stefanzweifel/git-auto-commit-action
6-
commit-user-name:
7-
type: string
8-
description: Name used for the commit user
9-
required: false
10-
default: github-actions[bot]
11-
commit-user-email:
12-
type: string
13-
description: Email address used for the commit user
14-
required: false
15-
default: 41898282+github-actions[bot]@users.noreply.github.com
16-
secrets:
17-
token:
18-
description: >
19-
Personal access token (PAT) used to fetch the repository. Required
20-
if the repository has any private submodules.
21-
required: false
224

235
jobs:
246
alias-release:
@@ -32,7 +14,7 @@ jobs:
3214
env:
3315
REPO: ${{ github.repository }}
3416
RUN_ID: ${{ github.run_id }}
35-
GH_TOKEN: ${{ secrets.token || github.token }}
17+
GH_TOKEN: ${{ github.token }}
3618
run: |
3719
ACTION_DATA=$(gh api "repos/$REPO/actions/runs/$RUN_ID")
3820
echo "::debug::$ACTION_DATA"
@@ -45,14 +27,14 @@ jobs:
4527
repository: uclahs-cds/tool-create-release
4628
path: reusable
4729
ref: ${{ steps.workflow-parsing.outputs.SHA }}
30+
token: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}
4831

4932
- name: Checkout calling repository
5033
uses: actions/checkout@v4
5134
with:
5235
path: caller
5336
fetch-depth: 0
5437
fetch-tags: true
55-
token: ${{ secrets.token || github.token }}
5638

5739
- name: Set up python
5840
uses: actions/setup-python@v5
@@ -65,11 +47,9 @@ jobs:
6547
# Update the alias if necessary
6648
- id: alias-release
6749
run: |
68-
git config --file "$REPO_DIR/.git/config" user.name "$COMMIT_USER"
69-
git config --file "$REPO_DIR/.git/config" user.email "$COMMIT_EMAIL"
50+
git config --file "$REPO_DIR/.git/config" user.name "github-actions[bot]"
51+
git config --file "$REPO_DIR/.git/config" user.email "41898282+github-actions[bot]@users.noreply.github.com"
7052
alias-release "$REPO_DIR" "$GITHUB_REF"
7153
env:
7254
REPO_DIR: caller
73-
GH_TOKEN: ${{ secrets.token || github.token }}
74-
COMMIT_USER: ${{ inputs.commit-user-name }}
75-
COMMIT_EMAIL: ${{ inputs.commit-user-email }}
55+
GH_TOKEN: ${{ github.token }}

.github/workflows/wf-finalize-release.yaml

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ on:
66
description: If true (the default), draft the release for later manual approval.
77
type: boolean
88
default: true
9-
attach-tarball:
10-
description: If true, attach a tarball including all submodules to the release.
11-
type: boolean
12-
default: false
13-
14-
secrets:
15-
token:
16-
description: >
17-
Personal access token (PAT) used to fetch the repository and submodules.
18-
Required if `draft` is false (to allow triggering alias workflow) or if
19-
`attach-tarball` is true _and_ one or more of the submodules are private.
20-
required: false
219

2210
jobs:
2311
finalize-release:
@@ -31,7 +19,7 @@ jobs:
3119
env:
3220
REPO: ${{ github.repository }}
3321
RUN_ID: ${{ github.run_id }}
34-
GH_TOKEN: ${{ secrets.token || github.token }}
22+
GH_TOKEN: ${{ github.token }}
3523
run: |
3624
ACTION_DATA=$(gh api "repos/$REPO/actions/runs/$RUN_ID")
3725
echo "::debug::$ACTION_DATA"
@@ -44,6 +32,7 @@ jobs:
4432
repository: uclahs-cds/tool-create-release
4533
path: reusable
4634
ref: ${{ steps.workflow-parsing.outputs.SHA }}
35+
token: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}
4736

4837
- name: Set up python
4938
uses: actions/setup-python@v5
@@ -53,29 +42,9 @@ jobs:
5342
# Install the bundled package
5443
- run: pip install ./reusable
5544

56-
- name: Establish variables for tarball attachment
57-
id: set-repo-name
58-
run: |
59-
REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2)
60-
echo "REPO_NAME=$REPO_NAME" >> "$GITHUB_OUTPUT"
61-
mkdir source
62-
echo "CLONE_PATH=source/$REPO_NAME" >> "$GITHUB_OUTPUT"
63-
64-
# Only check out the calling repository if we're going to attach a
65-
# tarball to the release
66-
- name: Clone repository to create tarball
67-
uses: actions/checkout@v4
68-
if: ${{ inputs.attach-tarball }}
69-
with:
70-
path: ${{ steps.set-repo-name.outputs.CLONE_PATH }}
71-
submodules: 'recursive'
72-
token: ${{ secrets.token || github.token }}
73-
7445
- name: Finalize release
75-
id: finalize-release
76-
run: finalize-release "$DRAFT" --archival-path "$CLONE_PATH"
46+
run: finalize-release "$DRAFT"
7747
env:
7848
DRAFT: ${{ inputs.draft }}
7949
# Use the other token to allow the aliasing workflow to run
80-
GH_TOKEN: ${{ secrets.token || github.token }}
81-
CLONE_PATH: ${{ steps.set-repo-name.outputs.CLONE_PATH }}
50+
GH_TOKEN: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}

.github/workflows/wf-prepare-release.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,10 @@ on:
2828
required: false
2929
version_files:
3030
type: string
31-
description: >
32-
Comma-separated list of relative paths to files with version numbers
33-
that should be updated. Every file must have exactly one line that
34-
looks like `version = "xxxx"` - some effort is made to handle
35-
different quoting styles, leading underscores, etc.
31+
description: Comma-separated list of relative paths to files with version numbers that should be updated. Every file must have exactly one line that looks like `version = "xxxx"` - some effort is made to handle different quoting styles, leading underscores, etc.
3632
required: false
3733
default: ""
3834

39-
secrets:
40-
token:
41-
description: >
42-
Personal access token (PAT) used to open the pull request. Must be
43-
provided in order for any actions to run in response to the PR
44-
creation.
45-
required: false
46-
4735
jobs:
4836
prepare-release:
4937
runs-on: ubuntu-latest
@@ -62,7 +50,7 @@ jobs:
6250
env:
6351
REPO: ${{ github.repository }}
6452
RUN_ID: ${{ github.run_id }}
65-
GH_TOKEN: ${{ secrets.token || github.token }}
53+
GH_TOKEN: ${{ github.token }}
6654
run: |
6755
ACTION_DATA=$(gh api "repos/$REPO/actions/runs/$RUN_ID")
6856
echo "::debug::$ACTION_DATA"
@@ -75,6 +63,7 @@ jobs:
7563
repository: uclahs-cds/tool-create-release
7664
path: reusable
7765
ref: ${{ steps.workflow-parsing.outputs.SHA }}
66+
token: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}
7867

7968
- name: Checkout calling repository
8069
uses: actions/checkout@v4
@@ -115,7 +104,7 @@ jobs:
115104
- name: Create Pull Request
116105
uses: peter-evans/create-pull-request@v7
117106
with:
118-
token: ${{ secrets.token || github.token }}
107+
token: ${{ secrets.UCLAHS_CDS_REPO_READ_TOKEN }}
119108
path: caller
120109
add-paths: ${{ inputs.changelog }},${{ inputs.version_files }}
121110
commit-message: ${{ steps.bump-changelog.outputs.commit_message }}

CHANGELOG.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
88

99
## Unreleased
1010

11-
### Added
12-
13-
- Add `attach-tarball` argument to finalize workflow to attach source tarball with release
14-
15-
### Changed
16-
17-
- Remove hard-coded UCLA secrets, add explicit `secrets` inputs to workflows
18-
- Automatically delete release branch after merging pull request
19-
2011
### Fixed
2112

2213
- Added `import mdformat.renderer` to fix issue with mdformat v0.7.22

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Usage of this tool requires adding three workflows to each calling repository (n
4949

5050
1. Create a new release with auto-generated notes and the target tag.
5151
* By default the new release is a draft, so no public release or tag are created without user intervention.
52-
1. Optionally, attach a source tarball including all submodules to the new release.
5352
1. Comment on the release PR with a link to the new release.
5453
1. Delete the merged release branch.
5554

@@ -115,14 +114,6 @@ Parameters can be specified using the [`with`](https://docs.github.com/en/action
115114
| `wf-prepare-release.yaml` | `changelog` | string | no | Relative path to the CHANGELOG file. Defaults to `./CHANGELOG.md`. |
116115
| `wf-prepare-release.yaml` | `timezone` | string | no | IANA timezone to use when calculating the current date for the CHANGELOG. Defaults to `America/Los_Angeles`. |
117116
| `wf-finalize-release.yaml` | `draft` | boolean | no | If true (the default), mark the new release as a draft and require manual intervention to continue. |
118-
| `wf-finalize-release.yaml` | `attach-tarball` | boolean | no | If true (not the default), attach a tarball of the repository source, including all submodules, to the release. |
119-
| `wf-alias-release.yaml` | `commit-user-name` | string | no | User name to use while tagging new commits (defaults to `github-actions[bot]`) |
120-
| `wf-alias-release.yaml` | `commit-user-email` | string | no | User email to use while tagging new commits (defaults to `41898282+github-actions[bot]@users.noreply.github.com`) |
121-
122-
All three workflows also accept a `token` secret which is required for full functionality (e.g. CI/CD checks on the opened pull request). The provided [personal access token](https://github.com/settings/tokens/new) should be stored as a secret in the repository and have the following scopes:
123-
124-
* `repo`
125-
* `workflow`
126117

127118
### Updating hard-coded strings with `version_files`
128119

bumpchanges/finalize.py

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from dataclasses import dataclass, field
1111
from pathlib import Path
12-
from typing import Optional
1312

1413

1514
from .logging import setup_logging, NOTICE, LoggingMixin
@@ -77,7 +76,7 @@ def __post_init__(self):
7776
except ValueError:
7877
pass
7978

80-
def create(self, draft: bool, archival_path: Optional[Path]):
79+
def create(self, draft: bool):
8180
"""Create the release and return the URL."""
8281
args = [
8382
"gh",
@@ -121,45 +120,6 @@ def create(self, draft: bool, archival_path: Optional[Path]):
121120
width=2000,
122121
)
123122

124-
# Create and upload a tarball if the archival path exists
125-
if archival_path:
126-
self.logger.info("Creating tarball")
127-
128-
tarball = Path(
129-
os.environ["GITHUB_WORKSPACE"],
130-
f"{archival_path.name}-{self.tag}.tar.gz",
131-
)
132-
133-
subprocess.run(
134-
["tar", "--exclude-vcs", "-czvf", tarball, archival_path.name],
135-
cwd=archival_path.parent,
136-
check=True,
137-
)
138-
139-
try:
140-
subprocess.run(
141-
[
142-
"gh",
143-
"release",
144-
"upload",
145-
self.tag,
146-
"--repo",
147-
self.owner_repo,
148-
f"{tarball}#Source code with submodules (tar.gz)",
149-
],
150-
check=True,
151-
)
152-
comment_body += (
153-
"\n\nA source tarball including all submodules "
154-
"has been attached to the release."
155-
)
156-
157-
except subprocess.CalledProcessError:
158-
self.logger.error("Failed to attach tarball to release!")
159-
comment_body += (
160-
"\n\n**ERROR:** Failed to attach source tarball to release!"
161-
)
162-
163123
subprocess.run(
164124
[
165125
"gh",
@@ -181,29 +141,15 @@ def entrypoint():
181141

182142
parser = argparse.ArgumentParser()
183143
parser.add_argument("draft", type=str_to_bool)
184-
parser.add_argument(
185-
"--archival-path", help="Path to a directory to tar and attach to the release"
186-
)
187144

188145
args = parser.parse_args()
189146

190147
try:
191148
# Parse the environment to create the release
192149
new_release = PreparedRelease.from_environment()
193150

194-
archival_path = Path(args.archival_path) if args.archival_path else None
195-
if archival_path and not archival_path.exists():
196-
archival_path = None
197-
198-
if archival_path:
199-
# Sanity-check that the cloned name matches the environment
200-
repo_name = new_release.owner_repo.split("/", maxsplit=1)[-1]
201-
if repo_name != archival_path.name:
202-
raise RuntimeError(f"{repo_name} != {archival_path.name}!")
203-
204151
# Draft or create the release
205-
new_release.create(args.draft, archival_path)
206-
152+
new_release.create(args.draft)
207153
except:
208154
logging.getLogger(__name__).exception("Failed to create new release")
209155
raise

templates/alias-release.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ permissions:
1616
jobs:
1717
update-alias:
1818
uses: uclahs-cds/tool-create-release/.github/workflows/wf-alias-release.yaml@v1
19-
secrets:
20-
token: ${{ secrets.YOUR_PAT }}
19+
secrets: inherit

templates/finalize-release.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ jobs:
1919
finalize-release:
2020
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'automation-create-release') }}
2121
uses: uclahs-cds/tool-create-release/.github/workflows/wf-finalize-release.yaml@v1
22+
secrets: inherit
2223
with:
2324
draft: false
24-
attach-tarball: false
25-
secrets:
26-
token: ${{ secrets.YOUR_PAT }}

templates/prepare-release-non-semantic-version.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ jobs:
2222
with:
2323
bump_type: "exact"
2424
exact_version: ${{ inputs.version }}
25-
secrets:
26-
token: ${{ secrets.YOUR_PAT }}
25+
secrets: inherit

templates/prepare-release.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ jobs:
2929
with:
3030
bump_type: ${{ inputs.bump_type }}
3131
prerelease: ${{ inputs.prerelease }}
32-
secrets:
33-
token: ${{ secrets.YOUR_PAT }}
32+
secrets: inherit

0 commit comments

Comments
 (0)