|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + enclave: |
| 6 | + type: string |
| 7 | + required: true |
| 8 | + description: 'Enclave to be released' |
| 9 | + options: |
| 10 | + - ethereum |
| 11 | + - optimism |
| 12 | + - parlia |
| 13 | + network: |
| 14 | + type: string |
| 15 | + required: true |
| 16 | + default: mainnet |
| 17 | + options: |
| 18 | + - testnet |
| 19 | + - mainnet |
| 20 | + description: 'The network on which the enclave runs.' |
| 21 | + tag: |
| 22 | + type: string |
| 23 | + required: true |
| 24 | + description: 'Tag Name (e.g. v1.2.3)' |
| 25 | + draft: |
| 26 | + type: boolean |
| 27 | + required: true |
| 28 | + default: false |
| 29 | + description: 'create a release as draft' |
| 30 | + prerelease: |
| 31 | + type: boolean |
| 32 | + required: true |
| 33 | + default: false |
| 34 | + description: 'create a release as prerelease' |
| 35 | + |
| 36 | +jobs: |
| 37 | + release: |
| 38 | + runs-on: ubuntu-24.04 |
| 39 | + permissions: |
| 40 | + contents: write # Push Tag and Create Release |
| 41 | + packages: write # Push Docker Image to ghcr.io |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + fetch-depth: 0 |
| 46 | + - name: Check if tag exists |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + OWNER: ${{ github.repository_owner }} |
| 50 | + REPO: ${{ github.event.repository.name }} |
| 51 | + TAG: ${{ github.event.inputs.enclave }}-${{ github.event.inputs.network }}-${{ github.event.inputs.tag }} |
| 52 | + run: | |
| 53 | + STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ |
| 54 | + -H "Authorization: token ${GITHUB_TOKEN}" \ |
| 55 | + "https://api.github.com/repos/${OWNER}/${REPO}/git/refs/tags/${TAG}") |
| 56 | + if [ "$STATUS" = "200" ]; then |
| 57 | + echo "🚫 Tag '${TAG}' already exists." |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | + - name: Configure Git user |
| 61 | + run: | |
| 62 | + git config user.name "github-actions[bot]" |
| 63 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 64 | + - uses: docker/setup-buildx-action@v3 |
| 65 | + - uses: docker/login-action@v3 |
| 66 | + with: |
| 67 | + registry: ghcr.io |
| 68 | + username: ${{ github.actor }} |
| 69 | + password: ${{ github.token }} |
| 70 | + logout: true |
| 71 | + - id: metadata |
| 72 | + uses: docker/metadata-action@v5 |
| 73 | + with: |
| 74 | + images: ghcr.io/${{ github.repository }}/${{ github.event.inputs.enclave }}/${{ github.event.inputs.network }} |
| 75 | + tags: | |
| 76 | + type=sha,prefix=,format=long |
| 77 | + ${{ github.event.inputs.tag }} |
| 78 | + - name: Build and Push |
| 79 | + uses: docker/build-push-action@v5 |
| 80 | + id: docker_build_and_push |
| 81 | + with: |
| 82 | + context: . |
| 83 | + push: true |
| 84 | + build-args: | |
| 85 | + LCP_ELC_TYPE=${{ github.event.inputs.enclave }} |
| 86 | + DEPLOYMENT_NETWORK=${{ github.event.inputs.network }} |
| 87 | + tags: ${{ steps.metadata.outputs.tags }} |
| 88 | + labels: ${{ steps.metadata.outputs.labels }} |
| 89 | + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/${{ github.event.inputs.enclave }}/${{ github.event.inputs.network }}:buildCache |
| 90 | + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/${{ github.event.inputs.enclave }}/${{ github.event.inputs.network }}:buildCache,mode=max |
| 91 | + - name: Create Release |
| 92 | + uses: softprops/action-gh-release@v2 |
| 93 | + with: |
| 94 | + name: ${{ github.event.inputs.enclave }}/${{ github.event.inputs.network }}/${{ github.event.inputs.tag }} |
| 95 | + tag_name: ${{ github.event.inputs.enclave }}-${{ github.event.inputs.network }}-${{ github.event.inputs.tag }} |
| 96 | + draft: ${{ github.event.inputs.draft }} |
| 97 | + prerelease: ${{ github.event.inputs.prerelease }} |
| 98 | + generate_release_notes: true |
| 99 | + append_body: true |
| 100 | + body: | |
| 101 | + ## Docker Image |
| 102 | + 1. Image Digest: ${{ steps.docker_build_and_push.outputs.imageid }} |
| 103 | + 2. [Link to Docker Repository](https://github.com/${{ github.repository }}/pkgs/container/${{ github.event.repository.name }}%2F${{ github.event.inputs.enclave }}%2F${{ github.event.inputs.network }}) |
0 commit comments