|
| 1 | +name: Nightly Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Manual trigger |
| 5 | + schedule: |
| 6 | + - cron: '0 5 * * *' # 5 AM UTC = Midnight EST |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + nightly: |
| 11 | + if: ${{ github.repository == 'liangyuanpeng/shipwright-triggers' }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + id-token: write # To be able to get OIDC ID token to sign images. |
| 15 | + contents: write # To be able to update releases. |
| 16 | + packages: write # To be able to push images and signatures. |
| 17 | + |
| 18 | + env: |
| 19 | + IMAGE_HOST: ghcr.io |
| 20 | + IMAGE_NAMESPACE: ${{ github.repository }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + - uses: actions/setup-go@v4 |
| 25 | + with: |
| 26 | + go-version: '1.19.x' |
| 27 | + check-latest: true |
| 28 | + |
| 29 | + # Install tools |
| 30 | + - uses: ko-build/[email protected] |
| 31 | + with: |
| 32 | + version: v0.13.0 |
| 33 | + - uses: imjasonh/setup-crane@e82f1b9a8007d399333baba4d75915558e9fb6a4 |
| 34 | + - uses: sigstore/cosign-installer@v3 |
| 35 | + |
| 36 | + - name: Get current date |
| 37 | + id: date |
| 38 | + run: echo "date=$(date +'%Y-%m-%d-%s')" >> $GITHUB_OUTPUT |
| 39 | + |
| 40 | + - name: Generate and upload release YAMLs |
| 41 | + env: |
| 42 | + REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + REGISTRY_USERNAME: ${{ github.repository_owner }} |
| 44 | + TAG: "nightly-${{ steps.date.outputs.date }}" |
| 45 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 46 | + run: | |
| 47 | + make release |
| 48 | +
|
| 49 | + mv release.yaml nightly-${{ steps.date.outputs.date }}.yaml |
| 50 | + mv release-debug.yaml nightly-${{ steps.date.outputs.date }}-debug.yaml |
| 51 | +# gh release upload nightly nightly-${{ steps.date.outputs.date }}.yaml |
| 52 | +# gh release upload nightly nightly-${{ steps.date.outputs.date }}-debug.yaml |
| 53 | + |
| 54 | + - name: Update latest tag of supporting images |
| 55 | + run: | |
| 56 | + crane copy "${IMAGE_HOST}/${IMAGE_NAMESPACE}/triggers:nightly-${{ steps.date.outputs.date }}" "${IMAGE_HOST}/${IMAGE_NAMESPACE}/triggers:latest" |
| 57 | +
|
| 58 | + - name: Sign released images |
| 59 | + run: | |
| 60 | + for f in \ |
| 61 | + nightly-${{ steps.date.outputs.date }}.yaml \ |
| 62 | + nightly-${{ steps.date.outputs.date }}-debug.yaml; do |
| 63 | + grep -o "ghcr.io[^\"]*" $f | xargs cosign sign --yes \ |
| 64 | + -a sha=${{ github.sha }} \ |
| 65 | + -a run_id=${{ github.run_id }} \ |
| 66 | + -a run_attempt=${{ github.run_attempt }} |
| 67 | + done |
0 commit comments