Skip to content

Commit 7345962

Browse files
committed
chore: Separate release and ci workfloas in GHA
This reduces the attack surface of the tests, since they no longer have any permissions to the repo. Also make the artifact upload conditional on a release being created, presumably it was a mistake before.
1 parent 86bc30a commit 7345962

4 files changed

Lines changed: 72 additions & 38 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ jobs:
3838
3939
distcheck:
4040
runs-on: ubuntu-latest
41-
permissions:
42-
# Permissions from https://github.com/googleapis/release-please-action?tab=readme-ov-file#basic-configuration
43-
# TODO: This is only needed for release, maybe split the release steps to a different job?
44-
contents: write
45-
pull-requests: write
46-
# Needed for adding labels for PRs, we shouldn't actually need this, see https://github.com/orgs/community/discussions/156181
47-
issues: write
48-
# attestations and id-token for attest-build-provenance
49-
attestations: write
50-
id-token: write
5141
strategy:
5242
matrix:
5343
include:
@@ -64,12 +54,6 @@ jobs:
6454
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6555
with:
6656
persist-credentials: false
67-
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
68-
with:
69-
config-file: .github/release-please-config.json
70-
manifest-file: .github/release-please-manifest.json
71-
id: release
72-
if: github.event_name == 'push' && matrix.dist == 'alpine'
7357
# A "container" workflow config would be cleaner here, but comes with
7458
# some restrictions/oddities: changes root's $HOME to /github/home
7559
# without changing the actual home dir that can cause some problems,
@@ -91,22 +75,3 @@ jobs:
9175
test/docker/entrypoint.sh
9276
env:
9377
NETWORK: ${{matrix.network}}
94-
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
95-
with:
96-
path: |
97-
bash-completion-*.tar.xz
98-
sha256sums.txt
99-
if: matrix.dist == 'alpine'
100-
- name: Upload release assets
101-
run: |
102-
set -x
103-
gh release upload ${RELEASE_PLEASE_TAG_NAME} \
104-
bash-completion-$(cat version.txt).tar.xz sha256sums.txt
105-
env:
106-
GH_TOKEN: ${{github.token}}
107-
RELEASE_PLEASE_TAG_NAME: ${{steps.release.outputs.tag_name}}
108-
if: steps.release.outputs.release_created
109-
- uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
110-
with:
111-
subject-checksums: sha256sums.txt
112-
if: steps.release.outputs.release_created
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: release-please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions: {}
9+
10+
jobs:
11+
release-please:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
# Permissions from https://github.com/googleapis/release-please-action?tab=readme-ov-file#basic-configuration
15+
contents: write
16+
pull-requests: write
17+
# Needed for adding labels to PRs, we shouldn't actually need this, see https://github.com/orgs/community/discussions/156181
18+
issues: write
19+
# attestations and id-token for attest-build-provenance
20+
attestations: write
21+
id-token: write
22+
steps:
23+
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
24+
with:
25+
config-file: .github/release-please-config.json
26+
manifest-file: .github/release-please-manifest.json
27+
id: release
28+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
if: steps.release.outputs.release_created
30+
with:
31+
persist-credentials: false
32+
# Use docker run instead of "container" workflow since that is what
33+
# ci.yaml uses, and it's unclear how to run a script from inside the
34+
# image.
35+
- name: Run main build
36+
if: steps.release.outputs.release_created
37+
run: >-
38+
docker run
39+
--rm
40+
--tty
41+
--volume $PWD:/usr/src/bash-completion
42+
--workdir /usr/src/bash-completion
43+
ghcr.io/scop/bash-completion/test:alpine
44+
./make-release.sh
45+
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
46+
if: steps.release.outputs.release_created
47+
with:
48+
path: |
49+
bash-completion-*.tar.xz
50+
sha256sums.txt
51+
- name: Upload release assets
52+
if: steps.release.outputs.release_created
53+
run: |
54+
set -x
55+
gh release upload ${RELEASE_PLEASE_TAG_NAME} \
56+
bash-completion-$(cat version.txt).tar.xz sha256sums.txt
57+
env:
58+
GH_TOKEN: ${{github.token}}
59+
RELEASE_PLEASE_TAG_NAME: ${{steps.release.outputs.tag_name}}
60+
- uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
61+
if: steps.release.outputs.release_created
62+
with:
63+
subject-checksums: sha256sums.txt

make-release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh -eux
2+
# shellcheck shell=sh
3+
4+
autoreconf -i
5+
./configure
6+
# TODO: Consider using the already created and tested tarball from the CI
7+
# workflow
8+
make distcheck
9+
sha256sum bash-completion-*.tar.* >sha256sums.txt

test/docker/entrypoint.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ fi
99
export bashcomp_bash=bash
1010
env
1111

12-
oldpwd=$(pwd)
1312
cp -a . /work
1413
cd /work
1514

@@ -30,5 +29,3 @@ make -j
3029

3130
xvfb-run make distcheck \
3231
PYTESTFLAGS="${PYTESTFLAGS---verbose -p no:cacheprovider --numprocesses=auto --dist=loadfile}"
33-
cp -p bash-completion-*.tar.* "$oldpwd/"
34-
sha256sum bash-completion-*.tar.* >"$oldpwd/sha256sums.txt"

0 commit comments

Comments
 (0)