Skip to content

Commit

Permalink
Composer package structure updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cvetty committed Jun 27, 2024
1 parent 9deffe4 commit 3e5582c
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 39 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Draft Release

on:
push:
branches:
# - main
- ci-cd-1
# paths-ignore:
# - "docs/**"
# - "*.yml"
# - "*.md"

jobs:
draft-release:
name: Draft Github Release
runs-on: ubuntu-20.04
steps:
- name: Draft github release
uses: actions/github-script@v6
with:
script: |
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
})
const filtered = releases.data.filter(release => release.draft == true && release.tag_name === 'unreleased');
if (filtered.length === 0) {
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
} else {
console.log("Deleting old untagged release")
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: filtered[0].id
})
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
}
135 changes: 98 additions & 37 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,115 @@
name: Release
name: Prerelease

on:
push:
branches:
# - main
- ci-cd-1
# paths-ignore:
# - "docs/**"
# - "*.yml"
# - "*.md"
workflow_dispatch:
inputs:
description:
description: 'Release notes'
type: string
default: ''
required: false
version-update:
description: 'Version update'
required: true
default: 'no update'
type: choice
options:
- major
- minor
- patch
- no update

env:
NODE_VERSION: "18.15.0"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write

jobs:
draft-release:
pre-release:
name: Draft Github Release
runs-on: ubuntu-20.04
steps:
- name: Draft github release
- name: Checkout the repo
uses: actions/checkout@v4
with:
ref: main
lfs: false

- uses: actions/setup-node@v4
with:
node-version: '18.20.3'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Setup Vals
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- name: Update package version
if: github.event.inputs.version-update != 'no update'
run:
npm version $VERSION_UPDATE --no-git-tag-version
env:
VERSION_UPDATE: ${{ github.event.inputs.version-update }}

- name: Update the beta version
id: create_tag
run: |
TAG=$(npm version prerelease --preid=beta -m "[GHA] Update package version to %s")
git push
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
git push --tags
- name: Set tag
uses: actions/github-script@v6
with:
script: |
const {TAG_NAME, USER, DESCRIPTION} = process.env
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
})
const filtered = releases.data.filter(release => release.draft == true && release.tag_name === 'unreleased');
if (filtered.length === 0) {
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
})
const filtered = releases.data.filter(release => release.draft == true && release.tag_name === 'unreleased');
let release;
if (filtered.length === 0) {
console.log("Creating a new untagged release")
release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
} else {
console.log("Deleting old untagged release")
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: filtered[0].id
})
console.log("Creating a new untagged release")
await github.rest.repos.createRelease({
release = filtered[0];
}
let releaseNotes = `${USER} released version ${TAG_NAME}.`;
if (DESCRIPTION) {
releaseNotes += `\n\n Release Notes:\n${DESCRIPTION}`;
}
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "unreleased",
name: "Unreleased",
draft: true,
generate_release_notes: true,
})
}
release_id: release.id,
name: TAG_NAME,
tag_name: TAG_NAME,
draft: false,
prerelease: true,
body: releaseNotes,
});
env:
TAG_NAME: ${{ steps.create_tag.outputs.tag }}
USER: ${{ github.event.sender.login }}
DESCRIPTION: ${{ github.event.inputs.description }}
4 changes: 2 additions & 2 deletions krait/composer.json → composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
},
"autoload": {
"psr-4": {
"MtrDesign\\Krait\\": "src/"
"MtrDesign\\Krait\\": "krait/src/"
}
},
"autoload-dev": {
"psr-4": {
"MtrDesign\\Krait\\Tests\\": "tests/"
"MtrDesign\\Krait\\Tests\\": "krait/tests/"
}
},
"extra": {
Expand Down

0 comments on commit 3e5582c

Please sign in to comment.