1111 workflow_dispatch :
1212 inputs :
1313 protect_ref :
14- description : ' Edera commit /branch/tag'
14+ description : ' Commit /branch/tag'
1515 default : ' '
1616
17- # Nightly build from HEAD
18- schedule :
19- - cron : " 0 9 * * *"
20-
2117 # Official stable versioned release
2218 release :
2319 types :
@@ -27,42 +23,9 @@ permissions:
2723 contents : read
2824
2925jobs :
30- # Implementing a gate like this isn't great since the workflow will still
31- # run on release events. Github Actions does not have a way to filter on
32- # tags for a release event yet so we are stuck with this. The other option
33- # was to use the push event and filter on tags but since we're using push
34- # events to publish unstable tags on main, it is cleaner to use release
35- # events to trigger a true release of stable artifacts.
36- release-gate :
37- name : ' Check if this is the correct GitHub release event'
38- runs-on : ubuntu-latest
39- permissions :
40- contents : read
41- outputs :
42- should_run : ${{ steps.check.outputs.should_run }}
43- steps :
44- - name : Harden the runner (Audit all outbound calls)
45- uses : step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
46- with :
47- egress-policy : audit
48-
49- - name : ' Check event'
50- id : check
51- run : |
52- echo "Since GitHub doesn't have a way to filter for specific tags in the release event we need to implement this dumb check"
53- run=true
54- if [[ '${{ github.event_name }}' == 'release' ]] && [[ '${{ github.ref_name }}' =~ 'chart-*' ]]; then
55- run=false
56- fi
57- echo "Workflow should run: ${run}"
58- echo "should_run=${run}" >> ${GITHUB_OUTPUT}
59-
6026 oci :
6127 name : ' Build and publish ${{ matrix.component }} images'
62- # Check if this is the proper release event.
63- # TODO: remove this when actions has a better answer
64- if : ${{ needs.release-gate.outputs.should_run == 'true' }}
65- needs : [release-gate]
28+ if : ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }}
6629 runs-on : ubuntu-latest
6730 strategy :
6831 fail-fast : false
@@ -146,3 +109,92 @@ jobs:
146109 env :
147110 TAGS : ' ${{ steps.meta.outputs.tags }}'
148111 DIGEST : ' ${{ steps.push.outputs.digest }}'
112+
113+ upload-artifact :
114+ if : ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }}
115+ name : Publish Binaries to Release
116+ permissions :
117+ contents : write
118+ strategy :
119+ fail-fast : false
120+ matrix :
121+ platform :
122+ - { os: linux, arch: x86_64, libc: musl, static: true, on: ubuntu-latest }
123+ - { os: linux, arch: aarch64, libc: musl, static: true, on: ubuntu-latest }
124+ binary :
125+ - edera-check
126+ runs-on : ' ${{ matrix.platform.on }}'
127+ steps :
128+ - name : Harden the runner (Audit all outbound calls)
129+ uses : step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
130+ with :
131+ egress-policy : audit
132+
133+ - name : Checkout repository
134+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
135+ with :
136+ fetch-depth : 0
137+ persist-credentials : false
138+
139+ - name : Install Rust toolchain
140+ uses : dtolnay/rust-toolchain@5d458579430fc14a04a08a1e7d3694f545e91ce6 # zizmor: ignore[stale-action-refs]
141+
142+ - name : ' Build and assemble ${{ matrix.binary }}'
143+ run : |
144+ set -e
145+
146+ # Build configuration
147+ TARGET="${{ matrix.platform.arch }}-unknown-linux-${{ matrix.platform.libc }}"
148+ rustup target add "$TARGET"
149+
150+ ${{ matrix.platform.static == true && 'export RUSTFLAGS="-Ctarget-feature=+crt-static"' || '' }}
151+
152+ cargo build --release --target "$TARGET"
153+
154+ # Platform name
155+ PLATFORM="${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.platform.libc }}"
156+
157+ # Tag name
158+ TAG="${{ github.event.release.tag_name }}"
159+ [ -z "$TAG" ] && TAG="${{ github.event.repository.default_branch }}"
160+
161+ # Assemble asset
162+ mkdir -p target/assets
163+ BINARY="${{ matrix.binary }}"
164+ OUTPUT_NAME="${BINARY}_${TAG}_${PLATFORM}"
165+
166+ cp "target/${TARGET}/release/${BINARY}" "target/assets/${OUTPUT_NAME}"
167+
168+ cd target/assets
169+ if command -v sha256sum >/dev/null 2>&1; then
170+ sha256sum "${OUTPUT_NAME}" > "${OUTPUT_NAME}.sha256"
171+ else
172+ shasum -a 256 "${OUTPUT_NAME}" > "${OUTPUT_NAME}.sha256"
173+ fi
174+
175+ - name : ' Upload ${{ matrix.binary }} to workflow run'
176+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
177+ with :
178+ name : ${{ matrix.binary }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.platform.libc }}
179+ path : target/assets/${{ matrix.binary }}_*
180+
181+ - name : Generate cultivator token
182+ if : ${{ github.event_name == 'release' }}
183+ uses : actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
184+ id : generate-token
185+ with :
186+ app-id : " ${{ secrets.EDERA_CULTIVATION_APP_ID }}"
187+ private-key : " ${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}"
188+
189+ - name : ' Upload release artifacts with retry'
190+ if : ${{ github.event_name == 'release' }}
191+ uses : nick-fields/retry-action@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
192+ with :
193+ timeout_minutes : 5
194+ max_attempts : 10
195+ retry_wait_seconds : 1
196+ command : |
197+ cd target/assets
198+ gh release upload "${{ github.event.release.tag_name }}" --clobber ./*
199+ env :
200+ GITHUB_TOKEN : " ${{ steps.generate-token.outputs.token }}"
0 commit comments