diff --git a/.github/workflows/buildandrelease.yml b/.github/workflows/buildandrelease.yml deleted file mode 100644 index cd2a212f..00000000 --- a/.github/workflows/buildandrelease.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build and Release - -on: - workflow_dispatch: - inputs: - version: - description: 'Netmaker version' - required: true - release: - types: [published] - -jobs: - version: - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.version.outputs.package_version }} - version: ${{ steps.version.outputs.version }} - steps: - - name: Get Version Number - id: version - run: | - if [[ -n "${{ github.event.inputs.version }}" ]]; then - NETMAKER_VERSION=${{ github.event.inputs.version }} - else - NETMAKER_VERSION=$(curl -fsSL https://api.github.com/repos/gravitl/netmaker/tags | grep 'name' | head -1 | cut -d'"' -f4) - fi - echo "VERSION=${NETMAKER_VERSION}" >> $GITHUB_OUTPUT - # remove everything but digits and . for package (deb, rpm, etc) versions - PACKAGE_VERSION=$(echo ${NETMAKER_VERSION} | tr -cd '[:digit:].') - echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT - netmaker-nmctl: - runs-on: ubuntu-latest - needs: version - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: release_${{ needs.version.outputs.version }} - fetch-depth: 0 - - run: git fetch --force --tags - - name: Setup go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - name: GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml new file mode 100644 index 00000000..28b9cb41 --- /dev/null +++ b/.github/workflows/packages.yml @@ -0,0 +1,46 @@ +name: Build linux packages +on: + workflow_call: + inputs: + version: + required: true + type: string + workflow_dispatch: + inputs: + version: + description: "netmaker version" + required: true + release: + types: [released] + +jobs: + + packages: + runs-on: ubuntu-latest + steps: + - name: setup ssh + run: | + mkdir -p ~/.ssh/ + echo "$SSH_KEY" > ~/.ssh/id_devops + chmod 600 ~/.ssh/id_devops + cat >>~/.ssh/config <> $GITHUB_ENV + echo ${VERSION} + - name: apt/rpm + run: | + ssh fileserver.clustercat.com "cd packages/nmcli; export VERSION=${{ ENV.version }}; export REVISION=0; ./buildall.sh " diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 75790aff..1685954e 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -6,8 +6,11 @@ on: tag: description: 'docker tag' required: true - release: - types: [published] + workflow_call: + inputs: + tag: + type: string + required: true jobs: docker: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..8dc3dc60 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,32 @@ +# creates a PR from release branch to master +name: Create Release PR to master +on: + workflow_call: + inputs: + version: + required: true + type: string + workflow_dispatch: + inputs: + version: + description: "netmaker version" + required: true + release: + types: [released] + +jobs: + pr-to-main: + runs-on: ubuntu-latest + steps: + - name: create pr + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh api --method POST \ + -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' \ + /repos/${{ github.repository }}/pulls \ + -f title='${{ github.event.inputs.version }}' \ + -f head='release_${{ github.event.inputs.version }}' \ + -f base="master" + + diff --git a/.github/workflows/purgeGHCR.yml b/.github/workflows/purgeGHCR.yml deleted file mode 100644 index 09edb8ba..00000000 --- a/.github/workflows/purgeGHCR.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Purge untagged images from GHCR - -on: - workflow_dispatch: - schedule: - - cron: '1 1 1 * *' -jobs: - purge: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Prune Netmaker - uses: vlaurin/action-ghcr-prune@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - organization: gravitl - container: netmaker - dry-run: false # Dry-run first, then change to `false` - untagged: true - - name: Prune Netclient - uses: vlaurin/action-ghcr-prune@main - with: - token: ${{ secrets.GITHUB_TOKEN }} - organization: gravitl - container: netclient - dry-run: false # Dry-run first, then change to `false` - untagged: true - diff --git a/.github/workflows/release-assets.yml b/.github/workflows/release-assets.yml new file mode 100644 index 00000000..d1919d69 --- /dev/null +++ b/.github/workflows/release-assets.yml @@ -0,0 +1,50 @@ +# generates release assets and uploads to release +name: Upload Release Assets +on: + workflow_call: + inputs: + version: + required: true + type: string + prerelease: + required: true + type: boolean + workflow_dispatch: + inputs: + version: + description: "netmaker version" + required: true + prerelease: + required: true + type: boolean + description: "prerelease" +jobs: + release-assets: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: release_${{ github.event.inputs.version}} + fetch-depth: 0 + - name: Get Tags + run: | + git fetch --force --tags + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: GoReleaser (full release) + if: ${{ github.event.inputs.prerelease == 'false'}} + uses: goreleaser/goreleaser-action@v4 + with: + args: release --clean --release-notes release.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: GoReleaser (prerelease) + if: ${{ github.event.inputs.prerelease == 'false'}} + uses: goreleaser/goreleaser-action@v4 + with: + args: release --clean --release-notes release.md -f .goreleaser.prerelease.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-branch.yml b/.github/workflows/release-branch.yml new file mode 100644 index 00000000..2dfdf1c8 --- /dev/null +++ b/.github/workflows/release-branch.yml @@ -0,0 +1,39 @@ +# creates new branch (release_{{ version }} with tag {{ version }} from develop +# will fail if branch or tag already exists on github +name: Create Release Branch +on: + workflow_call: + inputs: + version: + required: true + type: string + workflow_dispatch: + inputs: + version: + description: "netmaker version" + required: true +jobs: + release-branch: + runs-on: ubuntu-latest + steps: + - name: checkout develop + uses: actions/checkout@v3 + with: + ref: develop + - name: setup go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: setup git + run: | + git config user.name "Github Actions" + git config user.emaail "info@netmaker.io" + - name: create release Branch + run: | + git switch -c release_${{ github.event.inputs.version }} + git tag -f ${{ github.event.inputs.version }} + #push branch + git push origin release_${{ github.event.inputs.version }} + #push tag + git push origin ${{ github.event.inputs.version }} + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..bcb8749e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +# creates a release from develop +# creates release branch, generates release assets, publishes docker image and copies release.md to release +# if formal release, linux packages are generated and a PR from release branch to master is created +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: "new version number" + required: true + prerelease: + required: true + type: boolean + description: Is this a pre-release + +jobs: + + release-branch: + uses: ./.github/workflows/release-branch.yml + with: + version: ${{ github.event.inputs.version }} + + release-assets: + needs: release-branch + uses: ./.github/workflows/release-assets.yml + with: + version: ${{ github.event.inputs.version }} + prerelease: ${{ github.event.inputs.prerelease == 'true' }} + + docker: + needs: release-branch + uses: ./.github/workflows/publish-docker.yml + with: + tag: ${{ github.event.inputs.version }} + + packages: + if: ${{ github.event.inputs.prerelease == 'false' }} + needs: release-branch + uses: ./.github/workflows/packages.yml + with: + version: ${{ github.event.inputs.version }} + + pull-request: + if: ${{ github.event.inputs.prerelease == 'false' }} + needs: release-branch + uses: ./.github/workflows/pull-request.yml + with: + version: ${{ github.event.inputs.version }} diff --git a/.github/workflows/upgraderelease.yml b/.github/workflows/upgraderelease.yml new file mode 100644 index 00000000..50106875 --- /dev/null +++ b/.github/workflows/upgraderelease.yml @@ -0,0 +1,41 @@ +name: UpgradeRelease + +on: + workflow_dispatch: + inputs: + version: + description: "release/version to update" + required: true + +jobs: + + update: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + with: + ref: release_${{ github.event.inputs.version }} + fetch-depth: 0 + - run: | + git fetch --force --tags + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: goreleaser + uses: goreleaser/goreleaser-action@v4 + with: + args: release --clean --release-notes release.md -f .goreleaser.update.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + packages: + uses: ./.github/workflows/packages.yml + with: + version: ${{ github.event.inputs.version }} + + pull-request: + uses: ./.github/workflows/pull-request.yml + with: + version: ${{ github.event.inputs.version }} \ No newline at end of file diff --git a/.goreleaser.prerelease.yaml b/.goreleaser.prerelease.yaml new file mode 100644 index 00000000..0fb93ef2 --- /dev/null +++ b/.goreleaser.prerelease.yaml @@ -0,0 +1,34 @@ +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy +builds: + - main: ./ + env: + - CGO_ENABLED=1 + ldflags: + - -s -w + targets: + - linux_amd64 + binary: '{{ .ProjectName }}' + + - main: ./cli + id: 'nmctl' + env: + - CGO_ENABLED=0 + ldflags: + - -s -w + targets: + - linux_amd64 + - linux_arm64 + - darwin_amd64 + - darwin_arm64 + - freebsd_amd64 + - windows_amd64 + binary: 'nmctl' +archives: + - format: binary + name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}' +release: + prerelease: true + diff --git a/.goreleaser.update.yaml b/.goreleaser.update.yaml new file mode 100644 index 00000000..c87b01e5 --- /dev/null +++ b/.goreleaser.update.yaml @@ -0,0 +1,4 @@ +builds: + - skip: true +release: + prerelease: false diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b40fd361..8e6415b2 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -4,16 +4,16 @@ before: - go mod tidy builds: - main: ./ - id: "netmaker" env: - CGO_ENABLED=1 ldflags: - -s -w targets: - linux_amd64 - binary: netmaker + binary: '{{ .ProjectName }}' + - main: ./cli - id: "nmctl" + id: 'nmctl' env: - CGO_ENABLED=0 ldflags: @@ -25,9 +25,10 @@ builds: - darwin_arm64 - freebsd_amd64 - windows_amd64 - binary: nmctl + binary: 'nmctl' archives: - format: binary name_template: '{{ .Binary }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}' -changelog: - skip: true +release: + prerelease: false + diff --git a/release.md b/release.md new file mode 100644 index 00000000..67ba24c9 --- /dev/null +++ b/release.md @@ -0,0 +1,7 @@ +# Netmaker v0.18.1 + +## whats new + +## whats fixed + +## known issues