test-update #31
Workflow file for this run
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: Test | |
on: | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: main | |
persist-credentials: true | |
fetch-depth: 0 | |
token: ${{ secrets.J1_SRE_GITHUB_AUTOMATION_APP_ID }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.15.0 | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
- name: pr_labels | |
id: pr_labels | |
uses: joerick/[email protected] | |
- name: package_json | |
id: package_json | |
run: | | |
echo "version=$(jq -r .version < package.json)" >> $GITHUB_OUTPUT | |
- name: semver_versions | |
id: semver_versions | |
uses: "WyriHaximus/github-action-next-semvers@v1" | |
with: | |
version: ${{ steps.package_json.outputs.version }} | |
- name: patch_version | |
run: | | |
echo "NEW_VERSION=${{ steps.semver_versions.outputs.patch }}" >> $GITHUB_ENV | |
- name: minor_version | |
if: contains(steps.pr_labels.outputs.labels, 'minor') | |
run: | | |
echo "NEW_VERSION=${{ steps.semver_versions.outputs.minor }}" >> $GITHUB_ENV | |
# Parse the major version so we can extract only the major part of the semver (1 from 1.0.0) | |
- name: new_semver_parser | |
id: new_semver_parser | |
if: contains(steps.pr_labels.outputs.labels, 'major') | |
uses: booxmedialtd/ws-action-parse-semver@v1 | |
with: | |
input_string: ${{ steps.semver_versions.outputs.major }} | |
- name: major_version | |
if: contains(steps.pr_labels.outputs.labels, 'major') | |
run: | | |
echo "NEW_VERSION=${{ steps.new_semver_parser.outputs.major }}" >> $GITHUB_ENV | |
- name: echo_version_info | |
run: | | |
echo "current version is ${{ steps.package_json.outputs.version }}" | |
echo "new version will be ${{ env.NEW_VERSION }}" | |
- name: update_composite_tags | |
run: | | |
npm run update-composite-tags ${{ env.NEW_VERSION }} | |
- name: update_package_json_version | |
run: | | |
echo "`jq '.version="${{ env.NEW_VERSION }}"' package.json`" > package.json | |
- name: commit_updates | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Automation" | |
git add . | |
git commit -m "Updating composite tags and package.json version for v${{ env.NEW_VERSION }}" | |
- name: new_tags | |
run: | | |
git tag v${{ env.NEW_VERSION }} | |
git push --follow-tags --set-upstream origin main | |
# Parse the current version so we can extract only the major part of the semver (1 from 1.0.0) | |
- name: current_semver_parser | |
id: current_semver_parser | |
uses: booxmedialtd/ws-action-parse-semver@v1 | |
with: | |
input_string: ${{ steps.package_json.outputs.version }} | |
# We reset the major tag so workflow consumers automatically receive these changes | |
- name: reset_major_tag | |
if: ${{ env.NEW_VERSION != steps.current_semver_parser.outputs.major }} | |
run: | | |
git tag -f v${{ steps.current_semver_parser.outputs.major }} | |
git push origin v${{ steps.current_semver_parser.outputs.major }} --force |