Merge pull request #38 from unicef/docker-version #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Version tag to release (e.g. v1.2.3)" | |
| required: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| tag: ${{ steps.version.outputs.tag }} | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: apps/desktop/src-tauri -> target | |
| - name: Extract version from tag | |
| id: version | |
| shell: bash | |
| run: | | |
| REF="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}" | |
| VERSION="${REF#v}" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=${REF}" >> "$GITHUB_OUTPUT" | |
| - name: Set version in tauri.conf.json | |
| shell: bash | |
| run: | | |
| node -e " | |
| const fs = require('fs'); | |
| const p = 'apps/desktop/src-tauri/tauri.conf.json'; | |
| const conf = JSON.parse(fs.readFileSync(p, 'utf-8')); | |
| conf.version = '${{ steps.version.outputs.version }}'; | |
| fs.writeFileSync(p, JSON.stringify(conf, null, 2) + '\n'); | |
| " | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm build | |
| - uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| projectPath: apps/desktop | |
| tagName: ${{ steps.version.outputs.tag }} | |
| releaseName: "ADT Studio ${{ steps.version.outputs.tag }}" | |
| releaseBody: "" | |
| releaseDraft: false | |
| prerelease: false | |
| docker: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| target: app | |
| push: true | |
| tags: | | |
| ghcr.io/unicef/adt-studio:latest | |
| ghcr.io/unicef/adt-studio:${{ needs.release.outputs.tag }} | |
| - name: Generate standalone docker-compose.yml | |
| run: | | |
| TAG="${{ needs.release.outputs.tag }}" | |
| sed "s/__TAG__/${TAG}/g" docker/compose-release.yml.template > docker-compose.yml | |
| - name: Upload docker-compose.yml to release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ needs.release.outputs.tag }} docker-compose.yml \ | |
| --repo ${{ github.repository }} \ | |
| --clobber | |
| - name: Generate release notes | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| shell: bash | |
| run: | | |
| NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes \ | |
| -f tag_name=${{ github.ref_name }} \ | |
| --jq '.body') | |
| gh release edit ${{ needs.release.outputs.tag }} --notes "$NOTES" |