-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: Publish release | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- '**.md' | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
set-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.set-version.outputs.version }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: set version | ||
id: set-version | ||
run: | | ||
echo Faking a Semantic Version | ||
echo "version=1.$(date "+%Y%m%d%H%M%S")" >> ${GITHUB_OUTPUT} | ||
test: | ||
needs: | ||
- set-version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout latest code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Extract version of Go to use | ||
run: echo "GOVERSION=$(cat go.mod | grep -w "go" | awk ' { print $2 } ' | grep -w "^[^v]")" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v4.0.1 | ||
with: | ||
go-version: ${{ env.GOVERSION }} | ||
|
||
- name: Test Go | ||
run: | | ||
go mod tidy -v | ||
go test ./... -count=1 -coverprofile cover.out -short | ||
release: | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
needs: | ||
- set-version | ||
- test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout latest code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Extract version of Go to use | ||
run: echo "GOVERSION=$(cat go.mod | grep -w "go" | awk ' { print $2 } ' | grep -w "^[^v]")" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v4.0.1 | ||
with: | ||
go-version: ${{ env.GOVERSION }} | ||
|
||
- name: Create tag | ||
run: | | ||
git tag ${{ needs.set-version.outputs.version }} | ||
- uses: navikt/github-app-token-generator@v1 | ||
id: get-homebrew-token | ||
with: | ||
private-key: ${{ secrets.NAIS_APP_PRIVATE_KEY }} | ||
app-id: ${{ secrets.NAIS_APP_ID }} | ||
repo: nais/homebrew-tap | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
distribution: goreleaser | ||
version: v1.7.0 | ||
args: release -f .goreleaser.yaml --rm-dist --debug | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
HOMEBREW_PUSH_TOKEN: ${{ steps.get-homebrew-token.outputs.token }} | ||
SCOOP_PUSH_TOKEN: ${{ steps.get-scoop-token.outputs.token }} | ||
|
||
upload-ppa: | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
needs: | ||
- set-version | ||
- release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: navikt/github-app-token-generator@v1 | ||
id: get-token | ||
with: | ||
private-key: ${{ secrets.NAIS_APP_PRIVATE_KEY }} | ||
app-id: ${{ secrets.NAIS_APP_ID }} | ||
repo: nais/nais-ppa | ||
|
||
- name: Checkout nais-ppa | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: nais/nais-ppa | ||
token: ${{ steps.get-token.outputs.token }} | ||
path: pparepo | ||
|
||
- name: Add new deb to ppa | ||
id: update_ppa | ||
env: | ||
VERSION: ${{ needs.set-version.outputs.version }} | ||
EMAIL: aura@nav.no | ||
run: | | ||
echo "Version ${VERSION} was released, adding to PPA" | ||
cd pparepo | ||
# Fetch latest deb | ||
wget https://github.com/${{ github.repository }}/releases/download/${VERSION}/narc_${VERSION}.deb | ||
# Commit and push changes | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
git add narc_${VERSION}.deb | ||
git --no-pager diff --cached | ||
git commit --all --message "Add version ${VERSION} of narc-cli" | ||
git push | ||
upload-gar: | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
needs: | ||
- set-version | ||
- release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- id: "auth" | ||
name: "Authenticate to Google Cloud" | ||
uses: "google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033" # ratchet:google-github-actions/auth@v1.0.0 | ||
with: | ||
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: "gh-cli@nais-io.iam.gserviceaccount.com" | ||
token_format: "access_token" | ||
|
||
- name: 'Set up Cloud SDK' | ||
uses: 'google-github-actions/setup-gcloud@v1' | ||
with: | ||
install_components: beta | ||
|
||
- name: 'Upload new deb file to Google repository' | ||
env: | ||
VERSION: ${{ needs.set-version.outputs.version }} | ||
run: | | ||
echo "Version ${VERSION} was released, adding to PPA" | ||
# Fetch latest deb | ||
wget https://github.com/${{ github.repository }}/releases/download/${VERSION}/narc_${VERSION}.deb | ||
# Upload to GAR | ||
gcloud --project nais-io beta artifacts apt upload nais-ppa --quiet --source narc_${VERSION}.deb --location europe-north1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
project_name: narc-cli | ||
builds: | ||
- env: [ CGO_ENABLED=0 ] | ||
targets: | ||
- linux_amd64 | ||
- darwin_amd64 | ||
- darwin_arm64 | ||
id: narc | ||
dir: . | ||
main: ./cmd | ||
binary: narc | ||
ldflags: | ||
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
|
||
release: | ||
github: | ||
owner: nais | ||
name: narc | ||
header: | | ||
## narc-cli ({{ .Version }}) | ||
brews: | ||
- tap: | ||
owner: nais | ||
name: homebrew-tap | ||
token: "{{ .Env.HOMEBREW_PUSH_TOKEN }}" | ||
name: narc | ||
homepage: "https://github.com/nais/narc" | ||
description: "NAIS Administration CLI" | ||
folder: Formula | ||
install: | | ||
bin.install "narc" | ||
test: | | ||
assert_match version, shell_output("#{bin}/narc version") | ||
nfpms: | ||
- package_name: narc | ||
file_name_template: "{{ .PackageName }}_{{ .Version }}" | ||
vendor: NAV / nais team | ||
homepage: "https://github.com/nais/narc" | ||
maintainer: NAV / nais team | ||
description: "NAIS Administration CLI" | ||
license: MIT | ||
formats: | ||
- deb | ||
version_metadata: git |