From a38fa1c33e55934a4ddeb28410ec5dcb00afdd0d Mon Sep 17 00:00:00 2001 From: marcopiraccini Date: Wed, 13 Dec 2023 11:36:00 +0100 Subject: [PATCH] test release gh action Signed-off-by: marcopiraccini --- .github/workflows/release-draft.yml | 21 +++++++-- .github/workflows/release.yml | 67 ++++++++++++++++++++++++++--- README.md | 17 -------- package-lock.json | 4 +- package.json | 2 +- 5 files changed, 81 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml index c6b6b8db..4b8dd05c 100644 --- a/.github/workflows/release-draft.yml +++ b/.github/workflows/release-draft.yml @@ -3,6 +3,9 @@ name: release-draft on: workflow_dispatch: workflow_call: + inputs: + tag_name: + type: string push: branches: - main @@ -19,7 +22,11 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - run: echo "Creating Linux draft release for tag ${{ inputs.tag_name }}" + - uses: actions/checkout@v4.1.1 + with: + ref: ${{ inputs.tag_name }} + fetch-depth: 0 # https://github.com/actions/checkout/issues/1471 - uses: actions/setup-node@v4 with: node-version: 18 @@ -38,6 +45,7 @@ jobs: SM_CLIENT_CERT_FILE: D:\\Certificate_pkcs12.p12 SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} steps: + - run: echo "Creating Windows release for tag ${{ inputs.tag_name }}" - name: Set up certificate run: | echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12 @@ -77,7 +85,10 @@ jobs: with: node-version: 18 - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - uses: actions/checkout@v4.1.1 + with: + ref: ${{ inputs.tag_name }} + fetch-depth: 0 # https://github.com/actions/checkout/issues/1471 - run: npm ci - run: npm run build:win - run: npm run release:win @@ -92,7 +103,11 @@ jobs: APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - run: echo "Creating Mac release for tag ${{ inputs.tag_name }}" + - uses: actions/checkout@v4.1.1 + with: + ref: ${{ inputs.tag_name }} + fetch-depth: 0 # https://github.com/actions/checkout/issues/1471 - uses: actions/setup-node@v4 with: node-version: 18 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ca4c48d..a2e12b24 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,25 +2,78 @@ name: release on: workflow_dispatch: + inputs: + versionType: + type: choice + description: 'The type of release to create' + required: true + options: + - 'patch' + - 'minor' + - 'major' jobs: - # create-draft: - # uses: platformatic/meraki/.github/workflows/release-draft.yml@main + run-test: + name: Run Tests + uses: platformatic/meraki/.github/workflows/test.yml@main + + prepare-release: + name: Prepare release tag + needs: run-test + runs-on: ubuntu-latest + outputs: + TAG: v${{ steps.tag-name.outputs.TAG }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - id: version-bump + name: 'Automated Version Bump' + uses: 'phips28/gh-action-bump-version@master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + version-type: ${{ github.event.inputs.versionType }} + tag-prefix: 'v' + - name: Export TAG Parameter + id: tag-name + run: | + echo "TAG=`cat package.json | jq -r .version`" >> $GITHUB_OUTPUT + shell: bash + + create-draft: + needs: prepare-release + # TODO: restore `main` for the branch + name: Create Draft Release + uses: platformatic/meraki/.github/workflows/release-draft.yml@release-gh + with: + tag_name: ${{ needs.prepare-release.outputs.TAG }} + secrets: inherit + release: + name: Release + needs: create-draft runs-on: ubuntu-latest - steps: + steps: - name: Get last Draft id: last_release uses: InsonusK/get-latest-release@v1.0.1 # https://github.com/InsonusK/get-latest-release with: myToken: ${{ secrets.GITHUB_TOKEN }} - exclude_types: "release" + exclude_types: "release|prerelease" view_top: 1 - - name: "Print result" + + - name: "Print draft info" run: | + echo "Releasing:" echo "id: ${{ steps.last_release.outputs.id }}" echo "name: ${{ steps.last_release.outputs.name }}" echo "tag_name: ${{ steps.last_release.outputs.tag_name }}" echo "created_at: ${{ steps.last_release.outputs.created_atd }}" - echo "draft: ${{ steps.last_release.outputs.draft }}" - echo "prerelease: ${{ steps.last_release.outputs.prerelease }}" + + - name: "Publish Release" + uses: eregon/publish-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_id: ${{ steps.last_release.outputs.id }} + diff --git a/README.md b/README.md index cc965631..c763ec02 100644 --- a/README.md +++ b/README.md @@ -49,20 +49,3 @@ $ npm run build:mac $ npm run build:linux ``` -### Prepare a release tag - -Releases are created from tags, so you need to create a tag before you can create a release, e.g. if the current development version is `0.1.0`: - -```bash -git pull # Make sure you have the latest changes -git tag -a v0.1.0 -m "Release 0.1.0" -git push origin v0.1.0 -``` - -Then you have to do a version bump: -```bash -npm version --no-git-tag-version minor # or major, patch, etc. -git add package.json -git commit -m "version bump" -git push -``` diff --git a/package-lock.json b/package-lock.json index 3cf6f911..369e7643 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "meraki", - "version": "0.2.0", + "version": "0.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "meraki", - "version": "0.2.0", + "version": "0.2.8", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 32dd84cc..6e84397a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "meraki", "private": true, - "version": "0.2.0", + "version": "0.2.8", "main": "./out/main/index.js", "author": "Platformatic.dev", "license": "Apache-2.0",