chore(release): bump version to 0.1.2 #56
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: Draft Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: draft-release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| metadata: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| tag: ${{ steps.version.outputs.tag }} | |
| mode: ${{ steps.tag_state.outputs.mode }} | |
| release_enabled: ${{ steps.tag_state.outputs.release_enabled }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Read package version | |
| id: version | |
| shell: bash | |
| run: | | |
| version="$(python -c "import pathlib,re; text=pathlib.Path('Cargo.toml').read_text(); print(re.search(r'(?s)\[package\].*?version\s*=\s*\"([^\"]+)\"', text).group(1))")" | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$version" >> "$GITHUB_OUTPUT" | |
| - name: Check release tag state | |
| id: tag_state | |
| shell: bash | |
| run: | | |
| tag="${{ steps.version.outputs.tag }}" | |
| branch="${GITHUB_REF_NAME}" | |
| if [ "$branch" != "main" ]; then | |
| echo "mode=build" >> "$GITHUB_OUTPUT" | |
| echo "release_enabled=false" >> "$GITHUB_OUTPUT" | |
| elif ! tag_sha="$(git rev-list -n 1 "$tag" 2>/dev/null)"; then | |
| echo "mode=new" >> "$GITHUB_OUTPUT" | |
| echo "release_enabled=true" >> "$GITHUB_OUTPUT" | |
| elif [ "$tag_sha" = "$GITHUB_SHA" ]; then | |
| echo "mode=rerun" >> "$GITHUB_OUTPUT" | |
| echo "release_enabled=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "mode=skip" >> "$GITHUB_OUTPUT" | |
| echo "release_enabled=false" >> "$GITHUB_OUTPUT" | |
| echo "Version tag $tag already exists on commit $tag_sha. Skipping release for unchanged Cargo version." | |
| fi | |
| build-windows: | |
| needs: metadata | |
| if: needs.metadata.outputs.mode != 'skip' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| arch: x64 | |
| installer_arch: x64compatible | |
| - runner: windows-11-arm | |
| target: aarch64-pc-windows-msvc | |
| arch: arm64 | |
| installer_arch: arm64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust build | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: windows-${{ matrix.target }} | |
| - name: Install Inno Setup | |
| shell: pwsh | |
| run: choco install innosetup --no-progress --yes | |
| - name: Test | |
| shell: pwsh | |
| run: cargo test --locked --target ${{ matrix.target }} | |
| - name: Build packages | |
| shell: pwsh | |
| run: .\.github\scripts\package-release.ps1 -RepoRoot $pwd.Path -TargetTriple "${{ matrix.target }}" -ArchLabel "${{ matrix.arch }}" -InstallerArchitecture "${{ matrix.installer_arch }}" | |
| - name: Upload workflow artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: windows-release-${{ matrix.arch }} | |
| path: | | |
| target/${{ matrix.target }}/release/shadowsync-windows-${{ matrix.arch }}-portable-v${{ needs.metadata.outputs.version }}.zip | |
| target/${{ matrix.target }}/release/shadowsync-windows-${{ matrix.arch }}-setup-v${{ needs.metadata.outputs.version }}.exe | |
| build-macos: | |
| needs: metadata | |
| if: needs.metadata.outputs.mode != 'skip' | |
| env: | |
| MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }} | |
| MACOS_CERTIFICATE_P12_BASE64: ${{ secrets.MACOS_CERTIFICATE_P12_BASE64 }} | |
| MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} | |
| MACOS_NOTARY_APPLE_ID: ${{ secrets.MACOS_NOTARY_APPLE_ID }} | |
| MACOS_NOTARY_TEAM_ID: ${{ secrets.MACOS_NOTARY_TEAM_ID }} | |
| MACOS_NOTARY_APP_PASSWORD: ${{ secrets.MACOS_NOTARY_APP_PASSWORD }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: macos-latest | |
| target: aarch64-apple-darwin | |
| arch: arm64 | |
| - runner: macos-15-intel | |
| target: x86_64-apple-darwin | |
| arch: x64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust build | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: macos-${{ matrix.target }} | |
| - name: Test | |
| run: cargo test --locked --target ${{ matrix.target }} | |
| - name: Build release binary | |
| run: cargo build --release --locked --target ${{ matrix.target }} | |
| - name: Import macOS signing certificate | |
| if: ${{ env.MACOS_CERTIFICATE_P12_BASE64 != '' && env.MACOS_CERTIFICATE_PASSWORD != '' }} | |
| shell: bash | |
| run: | | |
| keychain_path="$RUNNER_TEMP/usb-mirror-sync.keychain-db" | |
| certificate_path="$RUNNER_TEMP/usb-mirror-sync-signing.p12" | |
| CERTIFICATE_PATH="$certificate_path" python - <<'PY' | |
| import base64 | |
| import os | |
| from pathlib import Path | |
| Path(os.environ["CERTIFICATE_PATH"]).write_bytes( | |
| base64.b64decode(os.environ["MACOS_CERTIFICATE_P12_BASE64"]) | |
| ) | |
| PY | |
| security create-keychain -p "" "$keychain_path" | |
| security set-keychain-settings -lut 21600 "$keychain_path" | |
| security unlock-keychain -p "" "$keychain_path" | |
| security import "$certificate_path" -k "$keychain_path" -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign -T /usr/bin/security | |
| existing_keychains="$(security list-keychains -d user | tr -d '"')" | |
| security list-keychains -d user -s "$keychain_path" $existing_keychains | |
| security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "" "$keychain_path" | |
| - name: Package macOS artifact | |
| shell: bash | |
| run: bash .github/scripts/package-macos.sh "$PWD" "${{ matrix.target }}" "${{ matrix.arch }}" | |
| - name: Upload workflow artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: macos-release-${{ matrix.arch }} | |
| path: | | |
| target/${{ matrix.target }}/release/shadowsync-macos-${{ matrix.arch }}-v${{ needs.metadata.outputs.version }}.tar.gz | |
| target/${{ matrix.target }}/release/shadowsync-macos-${{ matrix.arch }}-v${{ needs.metadata.outputs.version }}.dmg | |
| build-linux: | |
| needs: metadata | |
| if: needs.metadata.outputs.mode != 'skip' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| arch: x64 | |
| - runner: ubuntu-24.04-arm | |
| target: aarch64-unknown-linux-gnu | |
| arch: arm64 | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache Rust build | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| key: linux-${{ matrix.target }} | |
| - name: Install Linux UI dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev | |
| - name: Test | |
| run: cargo test --locked --target ${{ matrix.target }} | |
| - name: Build release binary | |
| run: cargo build --release --locked --target ${{ matrix.target }} | |
| - name: Package Linux artifact | |
| shell: bash | |
| run: bash .github/scripts/package-linux.sh "$PWD" "${{ matrix.target }}" "${{ matrix.arch }}" | |
| - name: Upload workflow artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: linux-release-${{ matrix.arch }} | |
| path: target/${{ matrix.target }}/release/shadowsync-linux-${{ matrix.arch }}-v${{ needs.metadata.outputs.version }}.tar.gz | |
| release: | |
| needs: | |
| - metadata | |
| - build-windows | |
| - build-macos | |
| - build-linux | |
| if: needs.metadata.outputs.release_enabled == 'true' | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| path: release-artifacts | |
| - name: Generate release notes | |
| id: notes | |
| shell: bash | |
| run: | | |
| tag="v${{ needs.metadata.outputs.version }}" | |
| gh api "repos/$GITHUB_REPOSITORY/releases/generate-notes" -X POST -f tag_name="$tag" -f target_commitish="$GITHUB_SHA" --jq .body > release-notes.md | |
| python .github/scripts/generate-release-notes.py \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --tag "$tag" \ | |
| --artifacts-dir "release-artifacts" \ | |
| --notes-file "release-notes.md" | |
| echo "path=$PWD/release-notes.md" >> "$GITHUB_OUTPUT" | |
| - name: Create or update draft release | |
| shell: bash | |
| run: | | |
| tag="v${{ needs.metadata.outputs.version }}" | |
| if gh release view "$tag" --repo "$GH_REPO" --json tagName >/dev/null 2>&1; then | |
| gh release edit "$tag" --repo "$GH_REPO" --draft --title "$tag" --notes-file "${{ steps.notes.outputs.path }}" | |
| else | |
| gh release create "$tag" --repo "$GH_REPO" --draft --title "$tag" --target "$GITHUB_SHA" --notes-file "${{ steps.notes.outputs.path }}" | |
| fi | |
| - name: Upload release assets | |
| shell: bash | |
| run: | | |
| tag="v${{ needs.metadata.outputs.version }}" | |
| find release-artifacts -type f -print0 | xargs -0 gh release upload "$tag" --repo "$GH_REPO" --clobber |