Skip to content

Commit

Permalink
build: add semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
taliesins committed Dec 21, 2023
1 parent 5d79058 commit 7ab008e
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 44 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ jobs:

- name: Create Changelog
id: release_number_and_changelog
uses: taliesins/conventional-changelog-action@releases/v3
uses: TriPSs/conventional-changelog-action@releases/v4
with:
github-token: ${{ secrets.CREATE_TAG_GITHUB_TOKEN }}
skip-version-file: 'true'
skip-on-empty: 'false'
skip-commit: 'true'
skip-tag: 'true'
dry-run: 'true'
#dry-run: 'true'
git-push: 'false'
tag-prefix: 'v'
output-file: 'false'

Expand All @@ -33,14 +34,14 @@ jobs:
FILE_DATA: ${{ steps.release_number_and_changelog.outputs.clean_changelog }}

- name: Create Changelog and commit
uses: taliesins/conventional-changelog-action@releases/v3
uses: TriPSs/conventional-changelog-action@releases/v4
with:
github-token: ${{ secrets.CREATE_TAG_GITHUB_TOKEN }}
skip-version-file: 'true'
skip-on-empty: 'false'
skip-commit: 'false'
skip-tag: 'false'
dry-run: 'false'
#dry-run: 'false'
force-push: 'true'
tag-prefix: 'v'
output-file: 'CHANGELOG.md'
59 changes: 19 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ jobs:
needs: [go_mod_download]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
Expand All @@ -265,7 +265,7 @@ jobs:
key: ${{ hashFiles('.github/workflows/release.yml') }}-${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }}
- name: goreleaser check
continue-on-error: true
uses: goreleaser/goreleaser-action@v4.2.0
uses: goreleaser/goreleaser-action@v5
with:
args: check
- name: Import GPG key
Expand All @@ -275,12 +275,25 @@ jobs:
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
#passphrase: ${{ secrets.PASSPHRASE }}

- name: Get tag_name
id: tag_name
if: startsWith(github.ref, 'refs/tags/v')
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Install dependencies
run: npm i -D semantic-release @semantic-release/{commit-analyzer,release-notes-generator,changelog,git,github}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: semantic-release $DRY_RUN_OPT

- name: goreleaser release
uses: goreleaser/goreleaser-action@v4.2.0
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
version: latest
Expand All @@ -289,51 +302,16 @@ jobs:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.tag_name.outputs.VERSION }}
- name: Create Changelog
id: release_number_and_changelog
uses: taliesins/conventional-changelog-action@releases/v3
if: "!(startsWith(github.ref, 'refs/tags/v'))"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
skip-version-file: 'true'
skip-on-empty: 'false'
skip-commit: 'true'
skip-tag: 'true'
dry-run: 'true'
tag-prefix: 'v'
output-file: 'CHANGELOG.md'
- name: Create clean changelog
uses: "finnp/create-file-action@master"
if: "!(startsWith(github.ref, 'refs/tags/v'))"
env:
FILE_NAME: ".github/CLEANCHANGELOG.md"
FILE_DATA: ${{ steps.release_number_and_changelog.outputs.clean_changelog }}

- name: Get release information
if: "!(startsWith(github.ref, 'refs/tags/v'))"
env:
CLEAN_CHANGELOG: ${{ steps.release_number_and_changelog.outputs.clean_changelog }}
CHANGELOG: ${{ steps.release_number_and_changelog.outputs.changelog }}
VERSION: ${{ steps.release_number_and_changelog.outputs.version }}
OLDVERSION: ${{ steps.release_number_and_changelog.outputs.old_version }}
TAG: ${{ steps.release_number_and_changelog.outputs.tag }}
SKIPPED: ${{ steps.release_number_and_changelog.outputs.skipped }}
run: |
echo "clean_changelog: $CLEAN_CHANGELOG"
echo "changelog: $CHANGELOG"
echo "version: $VERSION"
echo "old_version: $OLDVERSION"
echo "tag: $TAG"
echo "skipped: $SKIPPED"

- name: goreleaser snapshot
uses: goreleaser/goreleaser-action@v4.2.0
uses: goreleaser/goreleaser-action@v5
if: "!(startsWith(github.ref, 'refs/tags/v'))"
with:
args: release --rm-dist --skip-sign --snapshot --timeout ${{ env.RELEASE_TIME_OUT }} --release-notes=.github/CLEANCHANGELOG.md
env:
GORELEASER_CURRENT_TAG: v0.0.0
GORELEASER_PREVIOUS_TAG: v0.0.0

- name: snapshot artifact naming
id: naming
if: "!(startsWith(github.ref, 'refs/tags/v'))"
Expand All @@ -348,6 +326,7 @@ jobs:
ARTIFACT="${GITHUB_REF}";;
esac
echo "::set-output name=artifact::$ARTIFACT-$(date -u +'%Y-%m-%dT%H-%M')"
- name: upload snapshot artifact
uses: actions/upload-artifact@v3
if: "!(startsWith(github.ref, 'refs/tags/v'))"
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ website/vendor
*.winfile eol=crlf
/vendor
/act
/node_modules
/package-lock.json
/package.json
/.vs
/.idea
/.terraform
73 changes: 73 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"branches": [
"master",
{
"name": "develop",
"prerelease": true
}
],
"ci": true,
"debug": true,
"dryRun": true,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{ "tag": "Breaking", "release": "major" },
{ "tag": "Build", "release": "minor" },
{ "tag": "Chore", "release": "minor" },
{ "tag": "Fix", "release": "patch" },
{ "tag": "New", "release": "minor" },
{ "tag": "Update", "release": "minor" },
{ "tag": "Upgrade", "release": "minor" }
],
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING"
]
}
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "angular",
"releaseRules": [
{ "tag": "Breaking", "release": "major" },
{ "tag": "Build", "release": "minor" },
{ "tag": "Chore", "release": "minor" },
{ "tag": "Fix", "release": "patch" },
{ "tag": "New", "release": "minor" },
{ "tag": "Update", "release": "minor" },
{ "tag": "Upgrade", "release": "minor" }
],
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING"
]
},
"writerOpts": {
"commitsSort": [
"subject",
"scope"
]
}
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# HyperV Terraform Provider Changelog"
}
]
],
"repositoryUrl": "https:/taliesins/terraform-provider-hyperv",
"tagFormat": "v${version}"
}

0 comments on commit 7ab008e

Please sign in to comment.