release #9
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: "Release" | |
on: | |
workflow_dispatch: {} | |
repository_dispatch: | |
types: | |
- release | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.ORG_GITHUB_TOKEN }} | |
- name: Fetch All Tags | |
run: git fetch --force --tags | |
- name: Import GPG Key | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Set Release Version | |
id: version | |
run: | | |
echo "RELEASE_VERSION=$(date +v%Y.%-m.%-d)" >> $GITHUB_OUTPUT | |
- name: Ensure Release Does Not Exist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release delete ${{ steps.version.outputs.RELEASE_VERSION }} || true | |
- name: Set Package Version | |
run: | | |
cat << EOF > version.go | |
package opslevel_jq_parser | |
const ReleaseVersion = "${{ steps.version.outputs.RELEASE_VERSION }}" | |
EOF | |
- name: Ensure Changelog | |
run: | | |
git config user.name "OpsLevel Bots" | |
git config user.email "bots@opslevel.com" | |
if test -f ./.changes/${{ steps.version.outputs.RELEASE_VERSION }}.md | |
then | |
echo "Skip Changie..." | |
else | |
go install github.com/miniscruff/changie@latest | |
$(go env GOPATH)/bin/changie batch ${{ steps.version.outputs.RELEASE_VERSION }} | |
$(go env GOPATH)/bin/changie merge | |
git add . | |
git commit -m "Cut Release '${{ steps.version.outputs.RELEASE_VERSION }}'" | |
git push origin HEAD | |
fi | |
git tag -f ${{ steps.version.outputs.RELEASE_VERSION }} -m "Cut Release '${{ steps.version.outputs.RELEASE_VERSION }}'" | |
git push -f origin refs/tags/${{ steps.version.outputs.RELEASE_VERSION }} | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
args: release --rm-dist --release-notes=./.changes/${{ steps.version.outputs.RELEASE_VERSION }}.md | |
env: | |
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ORG_GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }} | |
- name: Report Release To OpsLevel | |
uses: opslevel/report-deploy-github-action@v0.7.0 | |
with: | |
integration_url: ${{ secrets.DEPLOY_INTEGRATION_URL }} | |
service: "opslevel_jq_parser" |