-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Lukas Maurer <[email protected]>
- Loading branch information
1 parent
bace31f
commit 6ee2309
Showing
12 changed files
with
716 additions
and
1,582 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Exit Prerelease Mode | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: 'Exit prerelease mode on release branch' | ||
type: string | ||
default: 'release-' | ||
required: true | ||
|
||
jobs: | ||
exit_prerelease: | ||
name: Changesets Exit Prerelease | ||
runs-on: ubuntu-latest | ||
# Allow GITHUB_TOKEN to have write permissions | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
# Check out the repository, using the Github Actions Bot app's token so | ||
# that we can push later. | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
# Checkout release branch entered when workflow was kicked off | ||
ref: ${{ github.event.inputs.branch }} | ||
# Fetch entire git history so Changesets can generate changelogs | ||
# with the correct commits | ||
fetch-depth: 0 | ||
|
||
- uses: ./.github/workflows/actions/turbo | ||
|
||
- name: Write latest version to package.json and package-lock.json | ||
run: | | ||
node ./scripts/exit-prerelease.js | ||
pnpm i --lockfile-only | ||
- name: Remove pre.json | ||
run: pnpm rimraf .changeset/pre.json | ||
|
||
- name: Commit and push changes | ||
run: | | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config user.name "github-actions[bot]" | ||
git add -A | ||
git commit -m "Exit prerelease mode" | ||
git push |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Prerelease | ||
|
||
on: | ||
push: | ||
branches: | ||
# Target release-x.x branches | ||
- 'release-*' | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
prerelease: | ||
name: Changesets Prerelease | ||
# Prevents changesets action from creating a PR on forks | ||
if: github.repository == 'siemens/ix' | ||
runs-on: ubuntu-latest | ||
# Permissions necessary for Changesets to push a new branch and open PRs | ||
# (for automated Version Packages PRs), and request the JWT for provenance. | ||
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: write | ||
steps: | ||
# Check out the repository, using the Github Actions Bot app's token so | ||
# that we can push later. | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: ./.github/workflows/actions/turbo | ||
|
||
- name: Check for pre.json file existence | ||
id: check_files | ||
uses: andstor/[email protected] | ||
with: | ||
files: '.changeset/pre.json' | ||
|
||
- name: Enter prerelease mode (alpha by default) | ||
# If .changeset/pre.json does not exist and we did not recently exit | ||
# prerelease mode, enter prerelease mode with tag alpha | ||
if: steps.check_files.outputs.files_exists == 'false' && !contains(github.event.head_commit.message, 'Exit prerelease') | ||
run: | | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config user.name "github-actions[bot]" | ||
pnpm changeset pre enter alpha | ||
git add -A | ||
git commit -m 'Enter prerelease mode' | ||
git push | ||
- name: Get prerelease changesets | ||
id: prerelease-changesets | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: '.changeset/pre.json' | ||
prop_path: 'changesets' | ||
|
||
- name: Create prerelease PR | ||
# Only attempt to create a PR if: | ||
# 1. .changeset/pre.json exists | ||
# 2. we are not actively publishing after merging a Version Packages PR | ||
# 3. AND we have prerelease changesets to publish (otherwise it errors) | ||
if: steps.check_files.outputs.files_exists == 'true' && !startsWith(github.event.head_commit.message, 'Version Packages') | ||
uses: changesets/action@v1 | ||
with: | ||
version: pnpm ci:version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish to npm + GitHub | ||
id: changesets | ||
# Only publish if we're still in pre mode and the last commit was | ||
# from an automatically created Version Packages PR | ||
if: steps.check_files.outputs.files_exists == 'true' && startsWith(github.event.head_commit.message, 'Version Packages') | ||
uses: changesets/action@v1 | ||
with: | ||
version: echo "This step should never version" | ||
publish: pnpm ci:publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
push: | ||
branches: | ||
- main | ||
- next | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: Snapshot Release | ||
|
||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
|
||
jobs: | ||
release_next: | ||
name: release:next | ||
runs-on: ubuntu-latest | ||
# Permissions necessary for Changesets to push a new branch and open PRs | ||
# (for automated Version Packages PRs), and request the JWT for provenance. | ||
# More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: write | ||
if: | | ||
github.repository == 'siemens/ix' && | ||
github.event.issue.pull_request && | ||
( | ||
github.event.sender.login == 'danielleroux' || | ||
github.event.sender.login == 'nuke-ellington' | ||
) && | ||
startsWith(github.event.comment.body, '/release:pr') | ||
steps: | ||
- uses: alessbell/[email protected] | ||
id: comment-branch | ||
|
||
- name: Get sha | ||
id: parse-sha | ||
continue-on-error: true | ||
run: | | ||
if [ "${{ steps.comment-branch.outputs.head_owner }}" == "siemens" ]; then | ||
echo "sha=${{ steps.comment-branch.outputs.head_sha }}" >> "${GITHUB_OUTPUT}" | ||
else | ||
sha_from_comment="$(echo $COMMENT_BODY | tr -s ' ' | cut -d ' ' -f2)" | ||
if [ $sha_from_comment == "/release:pr" ]; then | ||
exit 1 | ||
else | ||
echo "sha=$sha_from_comment" >> "${GITHUB_OUTPUT}" | ||
fi | ||
fi | ||
env: | ||
COMMENT_BODY: ${{ github.event.comment.body }} | ||
|
||
- name: Comment sha reminder | ||
if: steps.parse-sha.outcome == 'failure' | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
Did you forget to add the SHA? Please use `/release:pr <sha>` | ||
- name: Fail job | ||
if: steps.parse-sha.outcome == 'failure' | ||
run: | | ||
exit 1 | ||
- name: Checkout ref | ||
uses: actions/checkout@v4 | ||
with: | ||
## specify the owner + repository in order to checkout the fork | ||
## for community PRs | ||
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }} | ||
ref: ${{ steps.parse-sha.outputs.sha }} | ||
fetch-depth: 0 | ||
|
||
- name: Detect new changesets | ||
id: added-files | ||
run: | | ||
delimiter="$(openssl rand -hex 8)" | ||
echo "changesets<<${delimiter}" >> "${GITHUB_OUTPUT}" | ||
echo "$(git diff --name-only --diff-filter=A ${{ steps.comment-branch.outputs.base_sha }} ${{ steps.parse-sha.outputs.sha }} .changeset/*.md)" >> "${GITHUB_OUTPUT}" | ||
echo "${delimiter}" >> "${GITHUB_OUTPUT}" | ||
- uses: ./.github/workflows/actions/turbo | ||
|
||
- name: Check for pre.json file existence | ||
id: check_files | ||
uses: andstor/[email protected] | ||
with: | ||
files: '.changeset/pre.json' | ||
|
||
- name: Exit pre mode if pre.json exists | ||
# Changesets prevents us from generating a snapshot release | ||
# if we're in prerelease mode, so we remove `pre.json` if it exists | ||
# (but do not commit this change since we want the branch to remain | ||
# in pre mode) | ||
if: steps.check_files.outputs.files_exists == 'true' | ||
run: rm .changeset/pre.json | ||
|
||
- name: Add comment if no new changeset exists | ||
if: ${{ steps.added-files.outputs.changesets == '' }} | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
Please add a changeset via `pnpm changeset` before attempting a snapshot release. | ||
- name: Release to pr tag | ||
if: ${{ steps.added-files.outputs.changesets != '' }} | ||
run: | | ||
pnpm changeset version --snapshot pr-${{ github.event.issue.number }} && pnpm i --lockfile-only | ||
pnpm build --filter \!documentation | ||
pnpm changeset publish --no-git-tag --snapshot --tag snapshot | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Get released version | ||
if: ${{ steps.added-files.outputs.changesets != '' }} | ||
id: get-version | ||
run: echo "version=$(node -p "require('./packages/core/package.json').version")" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Create comment | ||
if: ${{ steps.added-files.outputs.changesets != '' }} | ||
uses: peter-evans/[email protected] | ||
with: | ||
issue-number: ${{ github.event.issue.number }} | ||
body: | | ||
A new release has been made for this PR. You can install it with: | ||
Core library: | ||
``` | ||
npm i @siemens/ix@${{ steps.get-version.outputs.version }} | ||
``` | ||
Angular: | ||
``` | ||
npm i @siemens/ix-angular@${{ steps.get-version.outputs.version }} | ||
``` | ||
React: | ||
``` | ||
npm i @siemens/ix-react@${{ steps.get-version.outputs.version }} | ||
``` | ||
Vue: | ||
``` | ||
npm i @siemens/ix-vue@${{ steps.get-version.outputs.version }} | ||
``` |
Oops, something went wrong.