Merge branch 'main' of https://github.com/GovCraft/paseto_cli #1
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
name: Update Package Version | ||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
required: true | ||
type: string | ||
secrets: | ||
token: | ||
required: true | ||
env: | ||
CARGO_TERM_COLOR: always | ||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.token }} | ||
- name: Update package.json version | ||
run: | | ||
package_json=$(cat package.json) | ||
# Update the version and optional dependencies | ||
new_version="${{ inputs.version }}" | ||
updated_package_json=$(echo "$package_json" | jq --arg new_version "$new_version" '.version = $new_version | .optionalDependencies."paseto_cli-linux-x64" = $new_version | .optionalDependencies."paseto_cli-darwin-x64" = $new_version | .optionalDependencies."paseto_cli-darwin-aarch64" = $new_version | .optionalDependencies."paseto_cli-windows-x64" = $new_version | .scripts.postinstall = "BINARY_DISTRIBUTION_VERSION=\($new_version) node ./install.js"') | ||
# Save the updated package.json content | ||
echo "$updated_package_json" > package.json | ||
# Check if changes were made and commit them | ||
if ! git diff --quiet; then | ||
echo "Version updated to $new_version and optional dependencies updated" >> $GITHUB_STEP_SUMMARY | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git commit -a -m "chore: workflow update package.json version to $new_version" | ||
git push | ||
else | ||
echo "Package.json version is already $new_version, no update needed" >> $GITHUB_STEP_SUMMARY | ||
fi | ||
shell: bash |