- Update workflow #3
This file contains 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
on: | ||
push: | ||
branches: [ main, ci* ] | ||
tags: [ v* ] | ||
pull_request: | ||
branches: [ main ] | ||
jobs: | ||
get-info: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
commit-hash: ${{ steps.git-info.outputs.commit-hash }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Get git info | ||
id: git-info | ||
shell: bash | ||
run: | | ||
COMMIT_HASH=$(git rev-parse --short ${{ GITHUB.SHA }}) | ||
echo "commit-hash=$COMMIT_HASH" >> $GITHUB_OUTPUT | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: get-info | ||
env: | ||
OUTPUT_FOLDER: 'pkg' | ||
RELEASE_FOLDER: 'release' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Rust | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
toolchain: 'nightly', | ||
target: 'wasm32-unknown-unknown' | ||
- name: Build with wasm-pack | ||
run: | | ||
cargo install wasm-pack | ||
wasm-pack build | ||
- name: List files | ||
run: | | ||
ls -la | ||
ls -la pkg | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: diff-match-patch-wasm_${{ needs.get-info.outputs.commit-hash }}_#${{ GITHUB.RUN_NUMBER }} | ||
path: ${{ env.OUTPUT_FOLDER }} | ||
- name: Prepare for release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
shell: bash | ||
run: | | ||
mkdir -p ${{ env.RELEASE_FOLDER }} | ||
7z a -tzip ${{ env.RELEASE_FOLDER }}/diff-match-patch-wasm.zip ${{ env.OUTPUT_FOLDER }}/* | ||
- name: Create release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
allowUpdates: true | ||
artifacts: ${{ env.RELEASE_FOLDER }}/diff-match-patch-wasm.zip |