Skip to content

Commit

Permalink
feat: update version and add go releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
gamunu committed Mar 4, 2024
1 parent d34132f commit b571876
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 111 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/add-copyright-headers.yml

This file was deleted.

93 changes: 26 additions & 67 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,36 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
type: string
sha:
description: 'SHA'
required: true
type: string
branch:
description: 'Branch'
required: true
type: choice
default: main
options:
- main
- pre-release
pull_request:
push:
# run only against tags
tags:
- "*"

jobs:
staging:
runs-on: ubuntu-latest
release:
runs-on: self-hosted
steps:
- name: Setup bob
uses: hashicorp/action-setup-bob@v1
- uses: actions/checkout@v4
with:
github-token:
${{ secrets.BOB_GITHUB_TOKEN }}
- name: Promote to staging
env:
BOB_GITHUB_TOKEN: ${{ secrets.BOB_GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
SHA: ${{ github.event.inputs.sha }}
BRANCH: ${{ github.event.inputs.branch }}
ENVIRONMENT: staging
run: |
bob trigger-promotion \
--product-name=terraform-ls \
--environment=terraform-ls-oss \
--org=hashicorp \
--repo=terraform-ls \
--slack-channel=C02AGQXCAF5 \
--product-version=$VERSION \
--sha=$SHA \
--branch=$BRANCH \
$ENVIRONMENT
fetch-depth: 0 # this is important, otherwise it won't checkout the full tree (i.e. no previous tags)

production:
runs-on: ubuntu-latest
needs: staging
steps:
- name: Setup bob
uses: hashicorp/action-setup-bob@v1
- uses: actions/setup-go@v5
with:
go-version: stable

- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: sigstore/[email protected] # installs cosign

- uses: goreleaser/goreleaser-action@v5 # run goreleaser
with:
github-token:
${{ secrets.BOB_GITHUB_TOKEN }}
- name: Promote to production
version: latest
args: release --rm-dist
env:
BOB_GITHUB_TOKEN: ${{ secrets.BOB_GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
SHA: ${{ github.event.inputs.sha }}
BRANCH: ${{ github.event.inputs.branch }}
ENVIRONMENT: production
run: |
bob trigger-promotion \
--product-name=terraform-ls \
--environment=terraform-ls-oss \
--org=hashicorp \
--repo=terraform-ls \
--slack-channel=C02AGQXCAF5 \
--product-version=$VERSION \
--sha=$SHA \
--branch=$BRANCH \
$ENVIRONMENT
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# .goreleaser.yaml
project_name: opentofu-ls

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- freebsd
- windows

archives:
- format: binary

checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
2 changes: 1 addition & 1 deletion internal/terraform/discovery/discovery_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

package discovery

const executableName = "terraform"
const executableName = "tofu"
2 changes: 1 addition & 1 deletion internal/terraform/discovery/discovery_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

package discovery

const executableName = "terraform.exe"
const executableName = "tofu.exe"
2 changes: 1 addition & 1 deletion version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.33.0-dev
0.1.0-dev

0 comments on commit b571876

Please sign in to comment.