Skip to content

Commit d8451f5

Browse files
authored
update script/build to support artifact_dir and use it everywhere in the release job
1 parent 6c353a5 commit d8451f5

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
gem_name: ${{ steps.build.outputs.gem_name }}
2222
gem_version: ${{ steps.build.outputs.gem_version }}
2323
gem_path: ${{ steps.build.outputs.gem_path }}
24+
artifact_dir: ${{ steps.build.outputs.artifact_dir }}
2425

2526
steps:
2627
- name: checkout
@@ -39,6 +40,7 @@ jobs:
3940
# gem_name: the name of the gem - ex: "my-cool-gem"
4041
# gem_version: the version of the gem - ex: "1.0.0"
4142
# gem_path: the path/filename of the gem - ex: "my-cool-gem-1.0.0.gem"
43+
# artifact_dir: the path to the dir where artifacts are stored - ex: "dist"
4244
- name: build
4345
id: build
4446
run: script/build
@@ -47,7 +49,9 @@ jobs:
4749
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # [email protected]
4850
id: upload-artifact
4951
with:
50-
path: "${{ steps.build.outputs.gem_path }}"
52+
name: ${{ steps.build.outputs.artifact_dir }}
53+
path: ${{ steps.build.outputs.artifact_dir }}
54+
if-no-files-found: error
5155

5256
release:
5357
needs: build
@@ -65,14 +69,20 @@ jobs:
6569
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # [email protected]
6670
with:
6771
artifact-ids: ${{ needs.build.outputs.artifact-id }}
72+
path: ${{ needs.build.outputs.artifact_dir }}
73+
74+
- name: view artifact
75+
env:
76+
ARTIFACT_PATH: ${{ needs.build.outputs.artifact_dir }}
77+
run: tree -L 2 -a --dirsfirst -C -F -h -D "${ARTIFACT_PATH}"
6878

6979
- name: Publish to GitHub Packages
7080
env:
7181
OWNER: ${{ github.repository_owner }}
7282
GEM_NAME: ${{ needs.build.outputs.gem_name }}
7383
GEM_VERSION: ${{ needs.build.outputs.gem_version }}
7484
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
ARTIFACT_PATH: "artifact"
85+
ARTIFACT_PATH: ${{ needs.build.outputs.artifact_dir }}
7686
run: |
7787
GEM_HOST_API_KEY=${GITHUB_TOKEN} gem push --key github --host https://rubygems.pkg.github.com/${OWNER} $ARTIFACT_PATH/${GEM_NAME}-${GEM_VERSION}.gem
7888
@@ -90,14 +100,14 @@ jobs:
90100
env:
91101
GEM_NAME: ${{ needs.build.outputs.gem_name }}
92102
GEM_VERSION: ${{ needs.build.outputs.gem_version }}
93-
ARTIFACT_PATH: "artifact"
103+
ARTIFACT_PATH: ${{ needs.build.outputs.artifact_dir }}
94104
run: bundle exec sigstore-cli sign ${ARTIFACT_PATH}/${GEM_NAME}-${GEM_VERSION}.gem --bundle ${GEM_NAME}-${GEM_VERSION}.sigstore.json
95105

96106
- name: Publish to RubyGems
97107
env:
98108
GEM_NAME: ${{ needs.build.outputs.gem_name }}
99109
GEM_VERSION: ${{ needs.build.outputs.gem_version }}
100-
ARTIFACT_PATH: "artifact"
110+
ARTIFACT_PATH: ${{ needs.build.outputs.artifact_dir }}
101111
run: gem push ${ARTIFACT_PATH}/${GEM_NAME}-${GEM_VERSION}.gem --attestation ${GEM_NAME}-${GEM_VERSION}.sigstore.json
102112

103113
- name: await gem
@@ -111,7 +121,7 @@ jobs:
111121
GEM_NAME: ${{ needs.build.outputs.gem_name }}
112122
GEM_VERSION: ${{ needs.build.outputs.gem_version }}
113123
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114-
ARTIFACT_PATH: "artifact"
124+
ARTIFACT_PATH: ${{ needs.build.outputs.artifact_dir }}
115125
run: |
116126
gh release create "v${GEM_VERSION}" \
117127
"${ARTIFACT_PATH}/${GEM_NAME}-${GEM_VERSION}.gem" \
@@ -130,12 +140,13 @@ jobs:
130140
steps:
131141
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # [email protected]
132142
with:
143+
path: ${{ needs.build.outputs.artifact_dir }}
133144
artifact-ids: ${{ needs.build.outputs.artifact-id }}
134145

135146
- name: attest build provenance
136147
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # [email protected]
137148
with:
138-
subject-path: "artifact/${{ needs.build.outputs.gem_path }}"
149+
subject-path: "${{ needs.build.outputs.artifact_dir }}/${{ needs.build.outputs.gem_path }}"
139150

140151
verify:
141152
permissions: {}
@@ -145,12 +156,13 @@ jobs:
145156
steps:
146157
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # [email protected]
147158
with:
159+
path: ${{ needs.build.outputs.artifact_dir }}
148160
artifact-ids: ${{ needs.build.outputs.artifact-id }}
149161

150162
- name: verify
151163
env:
152164
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153165
OWNER: ${{ github.repository_owner }}
154166
REPO: ${{ github.event.repository.name }}
155-
ARTIFACT_PATH: "artifact/${{ needs.build.outputs.gem_path }}"
167+
ARTIFACT_PATH: "${{ needs.build.outputs.artifact_dir }}/${{ needs.build.outputs.gem_path }}"
156168
run: gh attestation verify "$ARTIFACT_PATH" --repo ${OWNER}/${REPO} --signer-workflow ${OWNER}/${REPO}/.github/workflows/release.yml

script/build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ if [[ "$CI" == "true" ]]; then
1414
echo "gem_name=$GEM_NAME" >> $GITHUB_OUTPUT
1515
echo "gem_version=$GEM_VERSION" >> $GITHUB_OUTPUT
1616
echo "gem_path=$GEM_NAME-$GEM_VERSION.gem" >> $GITHUB_OUTPUT
17+
mkdir -p dist/
18+
mv $GEM_NAME-$GEM_VERSION.gem dist/
19+
ls -lah dist/
20+
echo "artifact_dir=dist" >> $GITHUB_OUTPUT
1721
fi
1822

1923
echo -e "📦 ${GREEN}successfully${OFF} built ${PURPLE}$GEM_NAME-$GEM_VERSION.gem${OFF}"

0 commit comments

Comments
 (0)