diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000..497ed08 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,43 @@ +on: + push: + branches: [ debug/* ] +name: Debug + +jobs: + debug: + runs-on: ubuntu-latest + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + + - name: Checkout source + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Cache go modules + uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.OS }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.OS }}-go-${{ env.cache-name }}- + ${{ runner.OS }}-go- + + - name: Setup dependencies + run: | + version="0.0.0-alpha.10" + echo "::group::Release notes" + git config --global user.email "milpa+ci@un.rob.mx" + git config --global user.name "Milpa CI" + git ls-remote | awk '/refs\/notes/ {print $2}' | while read -r noteKind; do + git pull --rebase origin "$noteKind" + done + + mkdir -p dist + git show "${version}" | awk '/^commit /{exit} f; /^Date: /{f=1}' > dist/release-notes.md + cat dist/release-notes.md + wc -c dist/release-notes.md + echo "::endgroup::" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c2c2cc8..8e02098 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,6 +31,8 @@ jobs: - name: Setup dependencies run: | + version="${GITHUB_REF##*/}" + echo "version is $version" echo "::group::install upx" curl -LO https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz tar xf upx-3.96-amd64_linux.tar.xz @@ -41,17 +43,22 @@ jobs: go build -ldflags "-s -w -X main.version=CI" -o compa echo "::endgroup::" - echo "::group::pull notes" - git config --global user.email "milpa+ci@un.rob.mx" - git config --global user.name "Milpa CI" - git ls-remote | awk '/refs\/notes/ {print $2}' | while read -r noteKind; do - git pull --rebase origin "$noteKind" - done + echo "::group::Release notes" + mkdir -p dist + refURL=$(curl --silent --show-error --fail \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/unRob/milpa/git/refs/tags/$version" | + jq -r .object.url) + curl --silent --show-error --fail \ + -H "Accept: application/vnd.github.v3+json" "$refURL" | + jq -r '.message' > dist/release-notes.md + + wc -c dist/release-notes.md + cat dist/release-notes.md echo "::endgroup::" go get -u github.com/mitchellh/gox - - name: create release id: build env: @@ -76,17 +83,11 @@ jobs: $(pwd)/milpa release build "${version}" echo "::endgroup::" - echo "::group::Setting release notes" - echo "RELEASE_NOTES<> "$GITHUB_ENV" - git show "${version}" | awk '/^commit /{exit} f; /^Date: /{f=1}' | tee -a "$GITHUB_ENV" - echo "EOF" >> "$GITHUB_ENV" - echo "::endgroup::" - - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - body: ${{ env.RELEASE_NOTES }} + body_path: dist/release-notes.md files: | dist/*.tgz dist/*.shasum diff --git a/repos/internal/commands/release/build.sh b/repos/internal/commands/release/build.sh index 6c3e2c7..96028b1 100644 --- a/repos/internal/commands/release/build.sh +++ b/repos/internal/commands/release/build.sh @@ -40,7 +40,8 @@ for pair in "${MILPA_ARG_TARGETS[@]//\//-}"; do rm -rf "${output:?}/$pair" cp -rv ./milpa ./.milpa LICENSE.txt README.md CHANGELOG.md "$dist_dir/" - tar -czf "$package" -C "$dist_dir/" milpa || @milpa.fail "Could not archive $package" + rm -rf "$package" + tar -czf "$package" -C "$(dirname "$dist_dir")" milpa || @milpa.fail "Could not archive $package" openssl dgst -sha256 "$package" | awk '{print $2}' > "${package##.tgz}.shasum" || @milpa.fail "Could not generate shasum for $package" done @milpa.log success "Archives generated"