diff --git a/.github/actions/get-version/action.yml b/.github/actions/get-version/action.yml new file mode 100644 index 00000000..98493567 --- /dev/null +++ b/.github/actions/get-version/action.yml @@ -0,0 +1,14 @@ +name: Get project version +description: Get the version for the current project defined in the `leptos-fluent/Cargo.toml` file +outputs: + version: + description: Version of the project + value: ${{ steps.get-version.outputs.version }} +runs: + using: composite + steps: + - id: get-version + shell: sh + run: | + echo "version=$(grep -oP --color=never '^version = "\K[^"]+' leptos-fluent/Cargo.toml)" \ + >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6361bf1f..cc42c666 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -346,10 +346,11 @@ jobs: - uses: actions/checkout@v4 - name: Setup Rust uses: hecrj/setup-rust-action@v2 + - name: Get project version + id: version + uses: ./.github/actions/get-version - name: Update version - run: | - version=$(grep -oP --color=never '^version = "\K[^"]+' leptos-fluent/Cargo.toml) - sed -i "s/^leptos-fluent-macros = .*/leptos-fluent-macros = \"$version\"/" leptos-fluent/Cargo.toml + run: sed -i "s/^leptos-fluent-macros = .*/leptos-fluent-macros = \"${{ steps.version.outputs.version }}\"/" leptos-fluent/Cargo.toml - name: Publish run: | cargo login ${{ secrets.CRATES_TOKEN }} @@ -400,6 +401,9 @@ jobs: uses: cargo-bins/cargo-binstall@main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get project version + id: version + uses: ./.github/actions/get-version - name: Install mdbook run: cargo binstall -y mdbook mdbook-admonish mdbook-toc env: @@ -409,8 +413,17 @@ jobs: cd book mdbook-admonish install . mdbook build + # create versioned copy + cd .. + cp -r book/dist book/v${{ steps.version.outputs.version }} - name: Deploy book uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./book/dist + - name: Deploy book v${{ steps.version.outputs.version }} + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./book/v${{ steps.version.outputs.version }} + destination_dir: v${{ steps.version.outputs.version }}