|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Tag-driven release, mirroring the .dev tag schema of the flamapy packages. |
| 4 | +# v1.2.3 -> docker :latest + :1.2.3, GitHub release, Render deploy |
| 5 | +# v1.2.3.dev0 -> docker :dev + :1.2.3.dev0 only (preview, no release/deploy) |
| 6 | +# Pushing to main no longer deploys; push a version tag to ship. |
| 7 | +on: |
| 8 | + push: |
| 9 | + tags: |
| 10 | + - v[0-9]+.[0-9]+.* |
| 11 | + |
| 12 | +jobs: |
| 13 | + docker: |
| 14 | + name: Build & publish Docker image |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + is_prerelease: ${{ steps.meta.outputs.is_prerelease }} |
| 18 | + steps: |
| 19 | + - name: Checkout the code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Compute image tags |
| 23 | + id: meta |
| 24 | + run: | |
| 25 | + VERSION=${GITHUB_REF_NAME} |
| 26 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 27 | + if [[ "$VERSION" == *dev* ]]; then |
| 28 | + echo "moving=dev" >> "$GITHUB_OUTPUT" |
| 29 | + echo "is_prerelease=true" >> "$GITHUB_OUTPUT" |
| 30 | + else |
| 31 | + echo "moving=latest" >> "$GITHUB_OUTPUT" |
| 32 | + echo "is_prerelease=false" >> "$GITHUB_OUTPUT" |
| 33 | + fi |
| 34 | +
|
| 35 | + # QEMU lets the amd64 runner also build the linux/arm64 image (Apple Silicon, |
| 36 | + # ARM servers); buildx is the multi-platform builder driving it. |
| 37 | + - name: Set up QEMU |
| 38 | + uses: docker/setup-qemu-action@v3 |
| 39 | + |
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@v3 |
| 42 | + |
| 43 | + - name: Log in to DockerHub |
| 44 | + uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 47 | + password: ${{ secrets.DOCKERHUB_API_TOKEN }} |
| 48 | + |
| 49 | + - name: Build and push the multi-arch Docker image |
| 50 | + uses: docker/build-push-action@v6 |
| 51 | + with: |
| 52 | + context: . |
| 53 | + file: Dockerfile |
| 54 | + platforms: linux/amd64,linux/arm64 |
| 55 | + push: true |
| 56 | + tags: | |
| 57 | + flamapy/flamapy-ide:${{ steps.meta.outputs.version }} |
| 58 | + flamapy/flamapy-ide:${{ steps.meta.outputs.moving }} |
| 59 | + build-args: | |
| 60 | + VITE_GA_MEASUREMENT_ID=${{ secrets.VITE_GA_MEASUREMENT_ID }} |
| 61 | + cache-from: type=gha |
| 62 | + cache-to: type=gha,mode=max |
| 63 | + |
| 64 | + github-release: |
| 65 | + name: Publish GitHub release |
| 66 | + needs: docker |
| 67 | + # Runs for every tag: real tags become full releases, .dev tags become |
| 68 | + # GitHub pre-releases (see prerelease/make_latest below). |
| 69 | + runs-on: ubuntu-latest |
| 70 | + # The repo's default GITHUB_TOKEN is read-only; creating a release needs write. |
| 71 | + permissions: |
| 72 | + contents: write |
| 73 | + steps: |
| 74 | + - name: Checkout git repo |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + # changelog-action diffs against the previous tag, so it needs full history. |
| 78 | + fetch-depth: 0 |
| 79 | + |
| 80 | + - name: Generate changelog |
| 81 | + id: changelog |
| 82 | + continue-on-error: true |
| 83 | + uses: Requarks/changelog-action@v1 |
| 84 | + with: |
| 85 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + tag: ${{ github.ref_name }} |
| 87 | + writeToFile: 'false' |
| 88 | + |
| 89 | + - name: Publish release github |
| 90 | + uses: softprops/action-gh-release@v2 |
| 91 | + with: |
| 92 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + tag_name: ${{ github.ref_name }} |
| 94 | + name: ${{ github.ref_name }} |
| 95 | + # Fall back to GitHub's auto-generated notes if the changelog step failed. |
| 96 | + body: ${{ steps.changelog.outputs.changes }} |
| 97 | + generate_release_notes: ${{ steps.changelog.outcome != 'success' }} |
| 98 | + # .dev tags publish as pre-releases and never become the "latest" release. |
| 99 | + prerelease: ${{ needs.docker.outputs.is_prerelease == 'true' }} |
| 100 | + make_latest: ${{ needs.docker.outputs.is_prerelease == 'false' }} |
| 101 | + |
| 102 | + deploy-render: |
| 103 | + name: Trigger Render deploy |
| 104 | + needs: docker |
| 105 | + if: needs.docker.outputs.is_prerelease == 'false' |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + - name: Deploy |
| 109 | + env: |
| 110 | + deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }} |
| 111 | + run: curl "$deploy_url" |
0 commit comments